comp.lang.ada
 help / color / mirror / Atom feed
From: Erik Sigra <sigra@home.se>
To: comp.lang.ada@ada.eu.org
Subject: How do I free unbounded strings?
Date: Mon, 5 Mar 2001 18:03:46 +0100
Date: 2001-03-05T18:03:46+01:00	[thread overview]
Message-ID: <mailman.983811905.13183.comp.lang.ada@ada.eu.org> (raw)

Hi,

This is my first post to this mailinglist/newsgroup. I use Gnat 3.13p 
downloaded from <http://www.gnuada.org/rpms313p.html>. In the rationale at 
<http://www.adapower.com/rationale/rat95-p3-a.html> i read:

  For unbounded strings the ":=" operation does the necessary storage
  management through Adjust and Finalize operations to allocate needed space
  for the new value of the target and to reclaim the space previously
  occupied by the object.

Then I tried this simple program:

  with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
  with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
  with Ada.Text_IO;                   use Ada.Text_IO;

  procedure Prov is
     Unbounded_String_1 : Unbounded_String;
  begin
     Put ("Enter an unbounded string: ");
     Unbounded_String_1 := Get_Line; --  First Pause
     Put ("Check how much memory the program uses and press return: ");
     while not End_Of_Line loop null; -- Second Pause
     end loop;
     Skip_Line;
     Unbounded_String_1 := Null_Unbounded_String;
     Put ("The unbounded string has been freed. Check how much memory the"
          & " program uses and press return: ");
     while not End_Of_Line loop null; -- Third Pause
     end loop;
     Skip_Line;
  end Prov;

At First Pause the program always uses (880, 880, 776) memory. At Second 
Pause the program uses at least (888, 888, 780) memory. If I enter a long 
string this can be for example (900, 900, 784). At Third Pause the program 
uses exactly as much memory as at Second Pause.

The memory values are labelled ("Virtual image size of process in Kbytes", 
"Resitent set size; Kbytes of program in memory", "Shared memory in Kbytes").

So it appears to me as if freeing doesn't work as the rationale says. Could 
someone please help me with this?




             reply	other threads:[~2001-03-05 17:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-05 17:03 Erik Sigra [this message]
2001-03-05 20:14 ` How do I free unbounded strings? Florian Weimer
2001-03-05 21:10   ` Erik Sigra
2001-03-06  1:49     ` Robert A Duff
2001-03-05 20:48 ` Jeffrey Carter
2001-03-05 20:55   ` Erik Sigra
2001-03-06  2:52 ` Mark Biggar
2001-03-06 14:10   ` Larry Kilgallen
replies disabled

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