[mercury-users] Heap space limited for C when called from Mercury?
Ralph Becket
rafe at cs.mu.OZ.AU
Tue Mar 11 23:09:41 AEDT 2003
Ondrej Bojar, Tuesday, 11 March 2003:
>
> Does this mean, that if I do not keep a pointer to the data on C global
> variables, C stack or Mercury stack then the garbage collector might
> (will) release the data from the memory.
Yes. The Boehm garbage collector knows about the following places where
pointers into the Mercury heap might be found:
- the stack(s) (in the high-level-C grades the C stack and the Mercury
stack are one and the same);
- the global variables in the program.
Hence if you have a pointer into the Mercury heap elsewhere, such as on
the C heap, then the Boehm collector will not see it and may therefore
reclaim space used for data that the C part of the program thinks is
still live.
> And then, when I look up the "extra" pointer stored on the C heap and
> dereference it, I touch the released memory block. Did I get it
> correctly?
Yes, the referenced memory may have been freed or reused for something
else.
Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list