From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14122 invoked by alias); 8 Jun 2009 09:43:55 -0000 Received: (qmail 14108 invoked by uid 22791); 8 Jun 2009 09:43:54 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from wf-out-1314.google.com (HELO wf-out-1314.google.com) (209.85.200.171) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 08 Jun 2009 09:43:48 +0000 Received: by wf-out-1314.google.com with SMTP id 25so995325wfc.14 for ; Mon, 08 Jun 2009 02:43:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.70.11 with SMTP id s11mr2472248wfa.141.1244454226920; Mon, 08 Jun 2009 02:43:46 -0700 (PDT) In-Reply-To: <4A2CD546.7030603@redhat.com> References: <898285d30906080005n72191f9bn8bf8eb76ff689d18@mail.gmail.com> <4A2CD546.7030603@redhat.com> Date: Mon, 08 Jun 2009 09:43:00 -0000 Message-ID: <898285d30906080243o70b109a0g54a6b3b00a87f4d2@mail.gmail.com> Subject: Re: Using libgcj with different memory management library. From: abhishek desai To: java@gcc.gnu.org Cc: Andrew Haley Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-06/txt/msg00023.txt.bz2 > 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. =46rom 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 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. =A0If 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-allocati= on > > Yes, it is. =A0Of course, you can always overload new in your own classes > to use the Boehm gc, evernif they don't derive from Object. =A0You'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. =A0The gc is a memory manager; how > can it use some other memory manager to do its own work? =A0You'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. =A0Is >> 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? =A0Doing the latter will be hard, the former easy. > > Andrew. > >