[gclist] Boehm's collector: mixing with standard malloc?

Stephan Rudlof Stephan.Rudlof@ipk.fhg.de
Tue, 07 Apr 1998 01:47:28 +0200


Boehm writes in README to version 4.12:

'...   Note that pointers inside memory allocated by the standard "malloc" are not
seen by the garbage collector.  Thus objects pointed to only from such a
region may be prematurely deallocated.  It is thus suggested that the
standard "malloc" be used only for memory regions, such as I/O buffers, that
are guaranteed not to contain pointers.  Pointers in C language automatic,
static, or register variables, are correctly recognized.  (Note that
GC_malloc_uncollectable has semantics similar to standard malloc,
but allocates objects that are traced by the collector.)
 ...'

I think, that should mean, that storing gc pointers (pointers underlying garbage collection) in standard malloc'ed memory areas is forbidden.

But storing standard malloc'ed pointers in standard malloc'ed mem areas should *not* be problematic in my opinion.

***Is that true?*** 

I 've just installed the collector - successfully - under Solaris 2.5.1.
I have to merge foreign object-code with self written code, more exactly: a Smalltalk (VisualWorks) engine with user routines. 
Redirecting standard malloc to GC_malloc for the resulting executable fails, because the collector reclaims some bitmaps (earlier there was a 'missing bitmap' error) resulting in X-errors and crashes. 

X11 Error:
Display:        0x40c69550
Serial: 0x00001fb5
Major:  59
Minor:  0
XID:    0x00000016
BadGC (invalid GC parameter)

But don't redirecting standard malloc and using GC_malloc* for my sources for leak detection is OK.

Another alternative would be to redirect to GC_malloc_uncollectable: This works but costs much time for a whole gc with reclaiming only my few pointers... And I don't have any sources of the Smalltalk engine...
But if I'm right (question above) then I don't need to choose this way.

Greetings,
-- 
sr (Stephan Rudlof (Stephan.Rudlof@ipk.fhg.de))
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3