[Gc] Faster to not call GC_free?

jim marshall jim.marshall at wbemsolutions.com
Mon Jun 4 17:37:15 PDT 2007


Bruce Hoult wrote:
> On 6/5/07, jim marshall <jim.marshall at wbemsolutions.com> wrote:
>> for example is there a set size of data that the GC will add to the ptr?
>> so I can maybe do
>>
>> memset(cptr, 0, ptrSize - GC_MEM_SIZE)
>
> The GC does not store any data in the objects that it gives you, and
> doesn't store any GC data next to them either  It gives you the same
> size or slightly larger object than you asked for.  You can write
> freely into it.
hmm, strange cause I was asking for 14 bytes and got back 80 bytes 
(that's more then a little bigger IMO), and doing the memset instead of 
GC_FREE caused the GC to think memory was corrupted and to abort. If I 
remove the memset and just do a GC_FREE I do not get corrupted memory. 
This is a program that has been working for over a year and the only 
change I have made is with the GC stuff (using GC_MALLOC_ATOMIC in 
places and then this GC_FREE thing).

>
> Of course if you put a C++ object in there then you have to watch out
> for VTBL pointers, which could be anywhere (with multiple
> inheritance).  But you're doing this after you're sure that you're
> never going to reference this object again, right?  So it's fine.
This is 100% C code, no C++ involved.
>
> The only thing you can't do is clear the object *after* doing a
> GC_FREE() on it.  It does have a link field in it then.
-Jim
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>
>
>

-- 
Jim Marshall
Sr. Staff Engineer
WBEM Solutions, Inc.
978-947-3607



More information about the Gc mailing list