Getting thread-local mem..

Peter Helfer peter.helfer.java at gmail.com
Fri Dec 7 06:02:12 PST 2007


The thing is, that I will not only allocate mem in one context, but rather
multiple times, so I cannot use a ResourceMark; I could use
AllocateHeap(size_t size, const char* name) /  FreeHeap(void* p) - but I
thought it would be of interest to keep the objects closely together, so not
much paging happens because of dispersedness... this is why I would like to
have it on a thread-local basis....

Regards, Peter


2007/12/7, Keith McGuigan <Keith.McGuigan at sun.com>:
>
>
> 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
> > |
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20071207/e7065ad7/attachment.html 


More information about the hotspot-runtime-dev mailing list