comp.lang.ada
 help / color / mirror / Atom feed
From: randhol+abuse@pvv.org (Preben Randhol)
Subject: Re: Problems freeing memory with Free
Date: Mon, 30 Apr 2001 07:35:48 +0000 (UTC)
Date: 2001-04-30T07:35:48+00:00	[thread overview]
Message-ID: <slrn9eq5ht.13j.randhol+abuse@kiuk0156.chembio.ntnu.no> (raw)
In-Reply-To: 87vgnn5p3q.fsf@deneb.enyo.de

On 30 Apr 2001 00:16:09 +0200, Florian Weimer wrote:
> randhol+abuse@pvv.org (Preben Randhol) writes:
> 
> There's no error.  A typical implementation of a storage pool
> retrieves memory in large chunks from the operating systems and
> allocates several objects in each chunk.  When the objects are freed,
> a chunk can only be returned to the operating system if all objects
> which had been allocated in it before have been freed (unless you've
> got a compacting garbage collector, but that's another story).

I see. So that explaines why if I delete X of the last nodes it frees
the memory, while if I free the X first or X in the middle, it may be
50_000 nodes or more the size has no influence apparently, it is not
freed as the OS thinks I still need the memory because the last node is
still using the memory at a much higher position?

The reason why I thought there was an error was that if I excange the
Data_Type with a record I have:

type Wordgroup_type is 
   record
      Word        :  Unbounded_String := To_Unbounded_String("");
      Explanation :  Unbounded_String := To_Unbounded_String("");
   end record;

and use this in the same way as the integer in the testing program I put
up on the web, then the program start apparently to leak memory if I
delete X nodes and then add X nodes again. The size of the memory goes
perhaps from:

   8Mb -> 8Mb (after freeing I don't see a reduction in memory size) ->
   12Mb (some increase, but not as high as 16Mb) or something like this,
   this does not happen if I use Bounded_String. The problem with
   Bounded_String however is that the memory consumption is 27Mb, well
   not in a real situation, but for my testing now :-)

I don't use New Wordgroup_type, nor an access type, do I need to to that
and set the generic Data_Type to Worgroup_Access_type instead and then
use Free on the Wordgroup as well?

> I think we discussed this phenomenon just a few months ago.

Ah, I'll dig back in my archive...

Thanks!

-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 �For me, Ada95 puts back the joy in programming.�



  reply	other threads:[~2001-04-30  7:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-29 20:29 Problems freeing memory with Free Preben Randhol
2001-04-29 22:16 ` Florian Weimer
2001-04-30  7:35   ` Preben Randhol [this message]
2001-04-30  8:01     ` Preben Randhol
2001-04-30 13:23     ` Larry Kilgallen
2001-05-01 12:30     ` Florian Weimer
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox