Page 1 of 1

Reference leak when using PointProcess.get_segment()

Posted: Sun Nov 09, 2014 7:12 pm
by lcampagn
This is an issue I ran into while debugging unit tests in pynrn:

Code: Select all

from neuron import h
s = h.Section()
c = h.IClamp(0.5, s)
g = c.get_segment()
del s
del c
del g
print "Sections:", len(list(h.allsec()))
print "IClamps: ", len(list(h.List('IClamp')))
The output looks like:

Code: Select all

Sections: 1
IClamps:  1
It looks like the Section and IClamp are not collected, but where are the leaked references?
I've tried using `gc.collect()` and `sys.exc_clear()`. I also tried using `gc.get_referrers()` to see where the references might be but the lists come back empty, so I assume the leak is internal to NEURON?

Re: Reference leak when using PointProcess.get_segment()

Posted: Tue Nov 11, 2014 7:46 am
by hines
This is "fixed" in http://www.neuron.yale.edu/hg/neuron/nr ... baac236c73
The reason "fixed" is in quotes is because the result of your fragment is now

Code: Select all

Sections: 0
IClamps:  1
and the IClamp ref count has not yet become 0 as it is temporarily being held by an internal buffer. One can tickle the system into releasing it by calling a method on any hoc object. e.g.

Code: Select all

h.Vector().size()
len(list(h.List('IClamp')))
0
I'm afraid I cannot, so far, figure out a way to safely eliminate that internal buffer. (after the h.Vector().size, the buffer holds a reference to the Vector instance).