sakthivp
sakthivp

Reputation: 21

memory command is not available even after compiled with TCL_MEM_DEBUG flag

I have memory related problem in my application on solaris9 environment where Tcl_DeleteInterp() function calls lot of free() and mutex_unlock() functions. To debug the problem i followed the below steps to compile tcl on solaris server (with TCL_MEM_DEBUG flag) but still i couldn't use the 'memory' command in my interpreter.

  1. Ran configure script on server (./configure –prefix=<directory needs to be installed> --enable-symbols=mem)
  2. Make clean all
  3. Make install (tcl libraries and tlcsh exe is copied to the path specified in step1)
  4. Compilation generated two libraries (libtcl8.4g.so and libtclstub8.4g.a), I copied libtcl8.4g.so as libtcl8.4.so to my app
  5. Copied tcl8.4 directory as well.
  6. I also copied the tclsh8.4 to $PROVHOME/bin and created soft link as tclsh-> tclsh8.4.
  7. From my application i linked the debug symbol enabled libraries to the place where exactly i created the Tcl interpreter.
  8. Initialized the Tcl interpreter to using Tcl_InitMemory() function (so that the memory command will be registered in the supplied(arg) interpreter.

When i used the interpreter exe (tclsh) separately i could execute the memory command, but when i used the same exe on my application its not working. Can someone help me what could be the possible reason for this problem ? Also help me how can i cross verify the libraries that they are compiled with TCL_MEM_DEBUG flag. Will the Tcl source code tar file contain Solaris directory where i have to build the libraries or should i use the unix source code for solaris platform as well ?

Thanks

Upvotes: 0

Views: 216

Answers (2)

Donal Fellows
Donal Fellows

Reputation: 137567

You're using Tcl embedded in your code? You need to call Tcl_InitMemory (passing in the handle to the interpreter where you want the memory command created) after creation of the interpreter and before you run user scripts, i.e., straight after the Tcl_CreateInterp gives you the handle (which should in turn come after the Tcl_FindExecutable call that initializes the shared parts of the library).

You must also make sure that everything is built with that flag set so that the correct memory allocation APIs are used in both your code when it integrates with Tcl, and you must make sure that you are linking against the debugging build. It's probably the linking that has gone wrong, but I've not done that level of development on Solaris for many years.

I think you'll find that “Getting a list of used libraries by a running process (unix)” is relevant to your problems.

Upvotes: 0

bch
bch

Reputation: 71

Are you using [mem] interactively (which does expansion of unambiguous short command names) and forgetting to use the full name ([memory]) in your scripts?

Upvotes: 0

Related Questions