On Mon, Mar 10, 2014 at 7:34 PM, Hendrik Greving < [email protected]> wrote:
> I am looking for the proper approach to do the following avoiding memory > leaks. I need to create some meta info for code objects, e.g. Crankshaft > compiled code. The meta info has to live as long as the code is in the code > cache, and is accessed from outside world. Right now, I am allocating space > (just using 'new') in Compiler::GetOptimizedCode and attach to code, by > putting in the same DECL_ACCESSORS as e.g. gc_metadata. My assumption is, > that hence garbage collection knows about the additional pointer in "class > Code", and that this space will get freed when the Code is release, too. Is > this assumption correct? > No. The garbage collector doesn't know anything about C++ memory. In fact, what you're describing is highly unsafe and only happens to work because the allocated object happens to be aligned, so the GC thinks it's a Smi and ignores it. You'll have to put your meta data into a heap object. Good luck. -- -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" 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/d/optout.
