Re: [tkined] Scotty memory problem

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Mon, 6 Dec 1999 15:51:53 +0100

>>>>> Matthew Upton writes:

Matthew> The following script also revealed continually increasing
Matthew> heap allocated memory. Am I doing something wrong here?

[...]

Matthew> Are there any know memory leaks when sending requests or
Matthew> creating/deleting sessions?

Memory leaks are plugged once they are known. Hence, there is no such
think as a known memory leak. ;-)

The memory leak was simple to reproduce and hence it is easy to fix
it. Here is are two patches that should do the trick:

diff -u -r1.4 tnmSnmpNet.c
--- tnmSnmpNet.c 1999/08/12 10:29:32 1.4
+++ tnmSnmpNet.c 1999/12/06 14:43:43
@@ -173,6 +173,7 @@
sockPtrPtr = &(*sockPtrPtr)->nextPtr;
}
*sockPtrPtr = sockPtr->nextPtr;
+ ckfree((char *) sockPtr);
}
}

diff -u -r1.23 tnmSnmpUtil.c
--- tnmSnmpUtil.c 1999/08/12 10:29:34 1.23
+++ tnmSnmpUtil.c 1999/12/06 14:50:47
@@ -203,6 +203,7 @@
Tcl_DecrRefCount(session->community);
Tcl_DecrRefCount(session->context);
Tcl_DecrRefCount(session->user);
+ Tcl_DecrRefCount(session->engineID);
if (session->readAuthKey) {
Tcl_DecrRefCount(session->readAuthKey);
}

There is another memory leak in tnmMibTcl.c, but you only hit this one
if you unset tnm(mibs):

diff -u -r1.27 tnmMibTcl.c
--- tnmMibTcl.c 1999/11/05 11:39:10 1.27
+++ tnmMibTcl.c 1999/12/06 14:47:24
@@ -616,6 +616,8 @@
part1Ptr = Tcl_NewStringObj("tnm", -1);
part2Ptr = Tcl_NewStringObj("mibs", -1);
listPtr = Tcl_ObjGetVar2(interp, part1Ptr, part2Ptr, TCL_GLOBAL_ONLY);
+ Tcl_DecrRefCount(part1Ptr);
+ Tcl_DecrRefCount(part2Ptr);
if (! listPtr) {
return TCL_OK;
}

/js

-- 
Juergen Schoenwaelder      Technical University Braunschweig
<schoenw@ibr.cs.tu-bs.de>  Dept. Operating Systems & Computer Networks
Phone: +49 531 391 3289    Bueltenweg 74/75, 38106 Braunschweig, Germany
Fax:   +49 531 391 5936    <URL:http://www.ibr.cs.tu-bs.de/~schoenw/>
--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.