Artifacts Associated With Ticket 1abbfcdff166b9f6
Ticket change [0d8d293dbe] (rid 137159) by sakthivp on 2014-03-06 10:13:48:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
I want to use the command 'memory' to see the memory allocations in Tcl interpreter. To achieve this, i have called the function Tcl_InitMemory() once after creating the Tcl interpreter with the interpreter handle as an argument(created using Tcl_CreateInterp() function). Will this suffice, to avail the memory command on an Interpreter ? or should i implement anything else ? Please help me with the required information.
- foundin initialized to: "8.4.9.1"
- is_private initialized to: "0"
- login: "sakthivp"
- priority initialized to: "5 Medium"
- private_contact initialized to: "48983f525fd9076bac622c146a176422b55d1e18"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "sakthivp"
- subsystem initialized to: "90. FAQs"
- title initialized to: "Information request regarding 'memory' command"
- type initialized to: "Support"
Ticket change [602251c7f4] (rid 137160) by sakthivp on 2014-03-06 10:15:08:
- login: "sakthivp"
- mimetype: "text/plain"
- priority changed to: "6"
Ticket change [f5e02961d2] (rid 137163) by dkf on 2014-03-06 13:51:28:
- icomment:
The whole Tcl library <b>must</b> be compiled with <tt>TCL_MEM_DEBUG</tt> defined, in order for the tracking hooks to be put in the memory management code <i>at all</i>. It's also recommended that you recompile your code with that symbol defined when using the Tcl library (so allocations via Tcl's APIs from your code also get tracked), though it shouldn't strictly be necessary. <p>The <b>supported way of doing this</b> is by passing <tt>--enable-symbols=mem</tt> to <tt>configure</tt> when building Tcl. (This implies <tt>--enable-symbols</tt>, and is implied by <tt>--enable-symbols=all</tt>, which turns on other types of debugging as well.) <p>This is in addition to calling <tt>Tcl_InitMemory</tt>. When <tt>TCL_MEM_DEBUG</tt> is <b>not</b> defined when building Tcl, <tt>Tcl_InitMemory</tt> is an empty function, a no-op.
- login: "dkf"
- mimetype: "text/html"
- subsystem changed to: "41. Memory Allocation"
- username: "dkf"
- icomment:
Ticket change [759e67e140] (rid 137164) by dkf on 2014-03-06 13:54:38:
- icomment:
For reference, the definition of <tt>Tcl_InitMemory</tt> in mem-debug mode is this: <pre> void Tcl_InitMemory( Tcl_Interp *interp) /* Interpreter in which commands should be * added */ { TclInitDbCkalloc(); Tcl_CreateCommand(interp, "memory", MemoryCmd, NULL, NULL); Tcl_CreateCommand(interp, "checkmem", CheckmemCmd, NULL, NULL); } </pre> Some of those functions mentioned are not exposed outside the Tcl library, and others are in the internal interfaces (which you're encouraged to ignore, and which are principally undocumented). - login: "dkf"
- mimetype: "text/html"
- username: "dkf"
- icomment:
Ticket change [83f9f51a54] (rid 137172) by sakthivp on 2014-03-07 05:25:36:
- icomment:
Thank yous so much for your answer. I will try the same with my program.
- login: "sakthivp"
- mimetype: "text/plain"
- icomment:
Ticket change [b3c8630c73] (rid 137173) by sakthivp on 2014-03-07 07:35:47:
- icomment:
I compiled the Tcl libraries with TCL_MEM_DEBUG symbol by configuring using below command. ./configure --prefix=/scratch/sakthi/Tcl_8.4.9_debug --enable-symbols=all I found a library with name libtcl8.4g.so. Then i wrote a C program which uses the debug shared object to invoke Tcl 'memory' command. The program failed to execute the 'memory' command. C program --------- #include <stdio.h> #include <tcl.h> #include <stdio.h> #include <tcl.h> int main() { int x=0; Tcl_Interp* a; a = Tcl_CreateInterp(); Tcl_Init(a); Tcl_InitMemory(a); if (a == NULL) printf("Interpreter creation Failed \n"); x = Tcl_Eval(a,(char *)"memory info"); Tcl_DeleteInterp(a); printf("DeleteInterpreter x=%d \n",x); } --------------------- Compilation flags on solaris10 server /opt/Studio11/SUNWspro/bin/CC -L/scratch/sakthi/Tcl_8.4.9_debug/lib -ltcl8.4g -I/scratch/sakthi/Tcl_8.4.9_debug/include Tcl_inter_problem.c -o Tcl_inter_problem ---------------------- Output of the program DeleteInterpreter x=1 // Tcl_Eval function returns 1 (TCL_ERROR), unable to execute memory command. Am i doing anything wrong? I have attached the Makefile which was generated by configure script. - login: "sakthivp"
- mimetype: "text/plain"
- icomment:
Add attachment "Makefile" [f4386ccf6a] (rid 137174) by sakthivp on 2014-03-07 07:38:47.