Ben, thanks for points.

I already found that it works only with 'complex' objects, and it is not
depends SMI/non-SMI values via some kind of performance benchmark, which
i'm use to measure/detect memory leak. It means that for heap-allocated
integer + persistent weak handle also can't be collected by GC.

My main concern is how it is must be implemented rightly to avoid memory
leaks. I'm little discouraged that rules about using weak handles is not
documented everywhere.

So now question is clear (there is V8 feature :) ). Thanks again for you
help!


On Sat, Apr 27, 2013 at 1:26 PM, Ben Noordhuis <[email protected]> wrote:

> On Sat, Apr 27, 2013 at 10:36 AM, Dmitry Azaraev
> <[email protected]> wrote:
> >> Boolean values are eternal --- they never die. Small integers (31 bits
> on
> >> ia32 and 32bits on x64) are
> >> not even allocated in the heap, they are *values* essentially so weak
> >> reachability is undefined for them.
> >    Thanks. I'm trying allocate non-SMI values too - and got same result,
> so
> > looks, that exists some additional rule. May be exist easy way to detect
> > which values can be used as weak headles or no?
>
> As a rule of thumb, you should only turn Objects* and Strings into
> Persistent handles.  Even then it may be a worthwhile tradeoff to just
> take the hit and construct a new object every time rather than caching
> it in a Persistent handle.  (Caveat emptor: as with all
> performance-related advice, don't take it on face value - benchmark
> it.)
>
> If you find yourself returning a lot of non-SMI numbers, it may be
> worth it to return them in a pre-allocated typed array rather than
> directly.  We use that trick in node.js to avoid excessive heap
> allocations.
>
> * That includes Arrays but if your array contains only numeric values,
> you can often use the typed array trick.
>
> --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/v8-users/616ZM3UWh2k/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Best regards,
   Dmitry

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to