www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/04/28/14:23:44

Subject: Yet more problems freeing memory
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Fri, 28 Apr 1995 15:52:51 +0100 (BST)
From: "B.S.Runnacles" <B DOT S DOT Runnacles AT soton DOT ac DOT uk>

Dear all..

I wrote recently of a problem I was having freeing up the memory associated 
with a linked list.  It transpires that go32 does not actually report 
the memory being returned to the heap.  My problem is that my code is leaking
memory somewhere, in that it progressively eats up more and more memory in
the large number of iterations required, eventually running out of swap space.  
I think I've traced the leak to the linked list objects I use, can anyone spot 
what is wrong here:

private:
listnode *Current,*Root

LinkedList::~LinkedList(void)
{
for(Current = Root; Current!=NULL; Current=Current->next) 
	delete Current;
}

I've tried the code on a number of GNU platforms (Solaris, LINUX) all to the
same effect. 

Is there any way I can profile the memory usage using gprof or some other tool?

Any suggestions would be much appreciated

Ben Runnacles
Image, Speech and Intelligent Systems Group
University of Southampton, UK.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019