Date: Wed, 26 Apr 1995 13:15:29 -0400 (EDT) From: Long Doan To: "B.S.Runnacles" Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: Unable to free memory.. On Wed, 26 Apr 1995, B.S.Runnacles wrote > LinkedList::~LinkedList(void) > { > listnode *Root,*Current; // a data structure with next pointer and data > _go32_dpmi_meminfo info1,info2; > for (Current = Root; Current != NULL; Current = Current->next) { > _go32_dpmi_get_free_memory_information(&info1); > delete Current; *** After Current is 'deleted', you shoudn't use Current->Next! *** I think that you're doing this backward. > _go32_dpmi_get_free_memory_information(&info2); > cout << info2.available_memory - info1.available_memory << endl; *** Also, delete and free () will not affect the value that _go32.._ () *** returns. The memory block is still freed, however. > } > } > > But the result says that there is no difference in the free memory before and > after the delete call. Has anyone got any ideas as to why? I may be doing > something fundementally wrong here, any hints would be nice. I think the > memory isn't being freed because after a few hundred iterations the code > falls over complaining of a full swap file. I think you're trying to use memory that was freed, and that prevent the library routines to do their job correctly. Hope that helps, Long. +--------------------------------------------------------+ | Long Doan ldoan1 AT osf1 DOT gmu DOT edu | | ld AT netrix DOT com | +--------------------------------------------------------+