* Using libgcj with different memory management library.
@ 2009-06-08 7:06 abhishek desai
2009-06-08 9:09 ` Andrew Haley
0 siblings, 1 reply; 4+ messages in thread
From: abhishek desai @ 2009-06-08 7:06 UTC (permalink / raw)
To: java
Hi,
I have a few questions regarding the memory management of libgcj.
1. As per my understanding libgcj uses boehm garbage collector for
memory allocations. Are there any allocations in libgcj which are not
routed to the garbage collector ? specially the parts of the library
written in C++. From what I understand is that the memory allocated
with the 'new' operator are routed to the gc . Is it necessary that
the class of object being allocated should be derived from the
'object' class for it to be allocated on the gc ? or all the
allocations with new get routed to gc ?
http://gcc.gnu.org/onlinedocs/gcj/Object-allocation.html#Object-allocation
2. I have a memory manager which allocates memory from a specific
memory pool. I want to port boehm gc to use this memory manager for
its allocations. Can someone give me some pointers as to where I can
make the necessary modifications ? I can see the gcconfig.h and
os_dep.c is the file containing the final system memory allocation
calls. Is there some other place I need to look at ? Are there any
tricky issues I need to look at while doing the porting ?
Just for information I am using an ancient version of gcc (version 3.4.6).
Regards,
Abhishek
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using libgcj with different memory management library.
2009-06-08 7:06 Using libgcj with different memory management library abhishek desai
@ 2009-06-08 9:09 ` Andrew Haley
2009-06-08 9:43 ` abhishek desai
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Haley @ 2009-06-08 9:09 UTC (permalink / raw)
To: abhishek desai; +Cc: java
abhishek desai wrote:
> 1. As per my understanding libgcj uses boehm garbage collector for
> memory allocations. Are there any allocations in libgcj which are
> not routed to the garbage collector ? specially the parts of the
> library written in C++. From what I understand is that the memory
> allocated with the 'new' operator are routed to the gc .
Not exactly. If you have a Java class, i.e. one which inherits from
java.lang.Object, then its new uses the GC.
> Is it necessary that the class of object being allocated should be
> derived from the 'object' class for it to be allocated on the gc ?
> or all the allocations with new get routed to gc ?
> http://gcc.gnu.org/onlinedocs/gcj/Object-allocation.html#Object-allocation
Yes, it is. Of course, you can always overload new in your own classes
to use the Boehm gc, evernif they don't derive from Object. You'll
have to make sure they're marked correctly, though.
> 2. I have a memory manager which allocates memory from a specific
> memory pool. I want to port boehm gc to use this memory manager for
> its allocations.
I don't understand how this can work. The gc is a memory manager; how
can it use some other memory manager to do its own work? You'll have
to explain a little more.
> Can someone give me some pointers as to where I can make the
> necessary modifications ? I can see the gcconfig.h and os_dep.c is
> the file containing the final system memory allocation calls. Is
> there some other place I need to look at ? Are there any tricky
> issues I need to look at while doing the porting ?
You'll need to the gc just to scan your memory pool, or also manage
it? Doing the latter will be hard, the former easy.
Andrew.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using libgcj with different memory management library.
2009-06-08 9:09 ` Andrew Haley
@ 2009-06-08 9:43 ` abhishek desai
2009-06-08 9:45 ` Andrew Haley
0 siblings, 1 reply; 4+ messages in thread
From: abhishek desai @ 2009-06-08 9:43 UTC (permalink / raw)
To: java; +Cc: Andrew Haley
> I don't understand how this can work. The gc is a memory manager; how
> can it use some other memory manager to do its own work? You'll have
> to explain a little more.
From what I understand GC uses GC_unix_get_mem to allocate memory
which calls mmap on /dev/zero on my system. This memory is managed by
GC for object allocation and also for GC internal working. I hope this
is correct. What I want to do is replace the mmap with my_malloc call
which will return a pointer to the allocated memory. my_malloc will
allocate memory from an internal fixed memory pool.
On Mon, Jun 8, 2009 at 2:39 PM, Andrew Haley<aph@redhat.com> wrote:
> abhishek desai wrote:
>
>> 1. As per my understanding libgcj uses boehm garbage collector for
>> memory allocations. Are there any allocations in libgcj which are
>> not routed to the garbage collector ? specially the parts of the
>> library written in C++. From what I understand is that the memory
>> allocated with the 'new' operator are routed to the gc .
>
> Not exactly. If you have a Java class, i.e. one which inherits from
> java.lang.Object, then its new uses the GC.
>
>> Is it necessary that the class of object being allocated should be
>> derived from the 'object' class for it to be allocated on the gc ?
>> or all the allocations with new get routed to gc ?
>> http://gcc.gnu.org/onlinedocs/gcj/Object-allocation.html#Object-allocation
>
> Yes, it is. Of course, you can always overload new in your own classes
> to use the Boehm gc, evernif they don't derive from Object. You'll
> have to make sure they're marked correctly, though.
>
>> 2. I have a memory manager which allocates memory from a specific
>> memory pool. I want to port boehm gc to use this memory manager for
>> its allocations.
>
> I don't understand how this can work. The gc is a memory manager; how
> can it use some other memory manager to do its own work? You'll have
> to explain a little more.
>
>> Can someone give me some pointers as to where I can make the
>> necessary modifications ? I can see the gcconfig.h and os_dep.c is
>> the file containing the final system memory allocation calls. Is
>> there some other place I need to look at ? Are there any tricky
>> issues I need to look at while doing the porting ?
>
> You'll need to the gc just to scan your memory pool, or also manage
> it? Doing the latter will be hard, the former easy.
>
> Andrew.
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Using libgcj with different memory management library.
2009-06-08 9:43 ` abhishek desai
@ 2009-06-08 9:45 ` Andrew Haley
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Haley @ 2009-06-08 9:45 UTC (permalink / raw)
To: abhishek desai; +Cc: java
abhishek desai wrote:
>> I don't understand how this can work. The gc is a memory manager; how
>> can it use some other memory manager to do its own work? You'll have
>> to explain a little more.
>
> From what I understand GC uses GC_unix_get_mem to allocate memory
> which calls mmap on /dev/zero on my system. This memory is managed by
> GC for object allocation and also for GC internal working. I hope this
> is correct. What I want to do is replace the mmap with my_malloc call
> which will return a pointer to the allocated memory. my_malloc will
> allocate memory from an internal fixed memory pool.
That will work fine.
Andrew.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-08 9:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-08 7:06 Using libgcj with different memory management library abhishek desai
2009-06-08 9:09 ` Andrew Haley
2009-06-08 9:43 ` abhishek desai
2009-06-08 9:45 ` Andrew Haley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).