Sublime Forum

Tracing down a memory leak (import resource?)

#1

Hello everyone. I have developed a plugin EasyClangComplete and it is working great for small to medium code bases. However, on a particularly large one, I see a memory leak. I still can’t measure it precisely, but I see plugin_host taking more and more memory. I’ve been trying to debug it in various methods. For example, pympler shows no memory leaks. I am now thinking of monitoring the memory continuously with the resource module. However, this module is not shipped with sublime text and seems to be not trivial to load from the *.so file. Does anyone have any ideas on how I can monitor the memory usage of the plugin from within sublime text?

1 Like

#2

You can compile python 3.3.6 from source:

./configure
make -j8
resource=$(find . -name 'resource.so')
cp $resource ~/Library/"Application Support"/"Sublime Text 3"/Packages/

In my console this’ll work:

>>> import resource
>>> dir(resource)
['RLIMIT_AS', 'RLIMIT_CORE', 'RLIMIT_CPU', 'RLIMIT_DATA', 'RLIMIT_FSIZE', 'RLIMIT_MEMLOCK', 'RLIMIT_NOFILE', 'RLIMIT_NPROC', 'RLIMIT_RSS', 'RLIMIT_STACK', 'RLIM_INFINITY', 'RUSAGE_CHILDREN', 'RUSAGE_SELF', '__doc__', '__file__', '__loader__', '__name__', '__package__', 'error', 'getpagesize', 'getrlimit', 'getrusage', 'setrlimit', 'struct_rusage']
0 Likes

#3

Thanks! I might try that. For now I have tried to symlink the resource.so from my distribution, but that did not work. This seems to be an obvious idea to build from source, don’t know how I did not think of it. Thanks again!

0 Likes

#4

Yeah, the minor version numbers must match exactly in order for this to work. Patch number doesn’t seem to matter. Good luck! :slightly_smiling_face:

0 Likes