On Mon, Apr 18, 2011 at 5:39 PM, quotient7 <[email protected]> wrote:
> On 18 Apr., 17:34, Matthias Ernst <[email protected]> wrote: > > A Persistent handle to the JS instance + MakeWeak let you register a > > callback that gets invoked by V8 when that instance was determined to be > > only weakly reachable. AdjustAmountOfExternalAllocatedMemory let's you > put > > "pressure" on the V8 GC - otherwise it might not run because it doesn't > know > > that there's external heap behind the small wrapper. > > Well, yes.. I'm completly new to v8 and try to realize that. Are there > any documentations about what "Weak" exactly means? > A "weak reference" is a concept common to most garbage collected languages (google "weak reference"). It allows you to refer to something but still let the GC collect it; in addition you can be notified about this. Seconly, what do you meah with "pressure"? The C++ instance should be > instantiated when "new MyClass" is called. Why do the GC needs to know > that there are other heap allocations? > It doesn't need to. However, the GC is optimized to run only when necessary. "Necessary" is defined in terms of JS heap space. If there's space left, no need to run. Wrappers around native objects are typically very small, so you can allocate millions on the JS heap without needing to collect them. "AdjustAmountOfExternalAllocatedMemory" allows you to inform the GC that there's hidden cost involved and trigger it to run more eagerly. I'm not positive, but I guess V8 will behave as if this amount had been allocated on the JS heap instead. > > > > > Pre-create the instance when you set up the FunctionTemplate for > "MyTest". > > Register the instance as "data" in FunctionTemplate::New . > > Thanks, this is fairly easy. > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
