Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Memory leaks 2400 bytes long.

Closed / Invalid1081975fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-12-09 10:07:32
I follow code to create and delete Tcl Interp. 

m_pInterp = Tcl_CreateInterp();
if (!Tcl_InterpDeleted(m_pInterp)) {
     Tcl_DeleteInterp(m_pInterp);
     Tcl_Finalize();
}

Is it right? It alway cause memory leaks.
dgpplain2004-12-09 23:10:07
Logged In: YES 
user_id=80530

If you place that code in a loop,
do you see memory usage grow?

Or is this just a one-time "leak" ?

A "leak" of 2400 bytes looks like
the tclFreeObjList which isn't
released until process exit.

You can build Tcl with -DPURIFY
to avoid that issue, and to get
leak detection tools like Purify
to not falsely complain.

If a -DPURIFY build still shows
trouble, or you see continued
growth in a loop, comment again
here to keep this report from closing.
nobodyplain2004-12-10 08:56:46
Logged In: NO 

Memory usage grow.

for(int i=0; i<5; i++)
{
    m_pInterp = Tcl_CreateInterp();
    if (!Tcl_InterpDeleted(m_pInterp)) 
    {
       Tcl_DeleteInterp(m_pInterp);
       Tcl_Finalize();
    }
}

{1829} normal block at 0x007A95A8, 2400 bytes long.
 Data: <                > 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 
{1402} normal block at 0x007A8C00, 2400 bytes long.
 Data: <                > 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 
{975} normal block at 0x007A8258, 2400 bytes long.
 Data: <                > 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 
{548} normal block at 0x007A78B0, 2400 bytes long.
 Data: <                > 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 
{104} normal block at 0x007A6F08, 2400 bytes long.
 Data: <                > 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 
Object dump complete.
hobbsplain2004-12-10 09:05:34
Logged In: YES 
user_id=72656

Take out the finalize - that's not valid in the loop, it
should be outside the loop (you only finalize and init once).
hungtvplain2004-12-10 17:01:02
Logged In: YES 
user_id=1172204

After I put Tcl_Finalize method outside the loop, Memory 
usage is not grow. Could you tell me how to add PURIFY to 
makefile.vc, please? Tcl core is used in Windows and Win CE.

Thanks.
dgp Ticket [1081975fff]: 1 change [History diff]2004-12-10 21:30:37
nobodyplain2004-12-15 15:05:52
Logged In: NO 

After I add PURIFY and rebuild the TCL. The memory leaks 
have been  removed. Thanks for your help
hobbs Closed ticket [1081975fff]. [History diff]2004-12-16 01:30:02
Log in (anonymous is fine) to add a comment.