Menu

#3005 Memory leaks 2400 bytes long.

obsolete: 8.4.9
closed-invalid
5
2004-12-15
2004-12-09
hungtv
No

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.

Discussion

  • Don Porter

    Don Porter - 2004-12-09

    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.

     
  • Don Porter

    Don Porter - 2004-12-09
    • assigned_to: hobbs --> dgp
    • status: open --> pending-invalid
     
  • Nobody/Anonymous

    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.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2004-12-10

    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).

     
  • hungtv

    hungtv - 2004-12-10
    • status: pending-invalid --> open-invalid
     
  • hungtv

    hungtv - 2004-12-10

    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.

     
  • Don Porter

    Don Porter - 2004-12-10
    • assigned_to: dgp --> hobbs
     
  • Nobody/Anonymous

    Logged In: NO

    After I add PURIFY and rebuild the TCL. The memory leaks
    have been removed. Thanks for your help

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2004-12-15
    • status: open-invalid --> closed-invalid