home *** CD-ROM | disk | FTP | other *** search
- From: kevinc@hpcc01.corp.hp.com (Kevin Collins)
- Date: Fri, 20 Nov 1992 16:20:13 GMT
- Subject: SC List Memory Leak?
- Message-ID: <1000011@hpcc01.corp.hp.com>
- Organization: the HP Corporate notes server
- Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!hpscit.sc.hp.com!scd.hp.com!hpscdm!hplextra!hpcc05!hpcc01!kevinc
- Newsgroups: comp.lang.c++
- Lines: 56
-
-
- I've been using an internal tool to detect memory leaks in some linked
- lists we use. I've been unable to get the SC List class to pass cleanly
- and want to know where I am going wrong.
-
- I've got a simple program which reads /etc/passwd, sticks Password objects
- onto a PasswordList class (with the put function), derived from SC List,
- then deletes them and the List itself. The two versions of the commands
- used to delete the objects on the List are :
-
- // method 1
-
- Password* P;
-
- if (length () > 0) {
-
- while ((*this).unput (P) != 0)
- delete P;
- }
-
- // method 2
-
- Password* PP;
-
- while ((void*)(*this)) {
- (*this).unput (PP);
- delete PP;
- }
-
- cout << "length = " << length () << endl;
-
- Both of these result in output like :
-
- only in dump 2: 1012 bytes, trace = malloc+0x0000004f
- mbschr+0x000000db
- __d_syserror+0x807a2207
- Pool::grow(void)+0x00000013
- D$4+0x0000002f
- D$6+0x00000027
- D$17+0x00000023
- fill__12PasswordListFv+0x0000027f
- main+0x00000097
-
- This basically shows the stack of calls that lead to the memory which
- was not de-allocated. 'fill__12PasswordListFv' is the 'fill" method of
- my PasswordList class. The call of "Pool::grow(void) is apparently
- something called by the List code which eventually calls malloc.
-
- Are my methods of clearing the List insufficient? Is there something
- else wrong?
-
- Please email any responses.
-
- Thanks,
-
- Kevin
-