Getting thread-local mem..

Keith McGuigan Keith.McGuigan at Sun.COM
Fri Dec 7 05:52:39 PST 2007

If you need the memory to stay alive only within a particular function scope 
(even a high-level one), you can use resource memory, which is thread-specific 
and is automatically cleaned up by a ResourceMark.  It is not global memory, 
though - it will be reclaimed when the ResourceMark destructor is called.  But 
if you put it at a high enough level maybe this will do what you need?

Take a look at allocation.hpp for info on this and other possibilities (for 
example if you are going to allocate out of C-heap, there are routines in there 
for doing that too).

- Keith

Peter Helfer wrote:
> I need some thread-local memory, which is not GC'd, but on death of 
> thread freed for sure (although I would call free for each alloced 
> elem). I've seen | threadLocalAllocBuffer.hpp 
> <file:///home/sgeorg/workspace/doxygenized/html/db/d09/threadLocalAllocBuffer_8hpp-source.html> 
> which offers HeapWord* allocate(size_t size) - but where is the 
> corresponding free(HeapWord* ) ?
> Or is there a better alternative - apart from using malloc/free directly ?
> Regards, Peter
> |

More information about the hotspot-runtime-dev mailing list