### to_python() causes big memory problems

Posted:

**Wed Sep 17, 2008 5:43 pm**Since the new version (6.2.3) came out I am using the to_python function to copy neuron vectors to python arrays.. The function to_python seems to allocate new memory that it never gives free again..

I wrote a simple example to illustrate this problem. (Points are spaces below)

Example 1:

16GB Memory fills within 30s:!!!!!

import neuron

h = neuron.h

h("""

objref vec

vec = new Vector(1000)

""")

for i in range(100000):

......a = range(1000)

......h.vec.to_python(a)

######################

Example 2:

Everthing OK!

import neuron

h = neuron.h

h("""

objref vec

vec = new Vector(1000)

""")

a = range(1000)

for i in range(100000):

......h.vec.to_python(a)

################

Example 3:

Everthing OK:

import neuron

h = neuron.h

h("""

objref vec

vec = new Vector(1000)

""")

for i in range(100000):

......a = range(1000)

h.vec.to_python(a)

I need to run a loop and the vector I record I do not know the size of before my loop starts, so I need example 1 to be working....

Any ideas, any help?

Armin

I wrote a simple example to illustrate this problem. (Points are spaces below)

Example 1:

16GB Memory fills within 30s:!!!!!

import neuron

h = neuron.h

h("""

objref vec

vec = new Vector(1000)

""")

for i in range(100000):

......a = range(1000)

......h.vec.to_python(a)

######################

Example 2:

Everthing OK!

import neuron

h = neuron.h

h("""

objref vec

vec = new Vector(1000)

""")

a = range(1000)

for i in range(100000):

......h.vec.to_python(a)

################

Example 3:

Everthing OK:

import neuron

h = neuron.h

h("""

objref vec

vec = new Vector(1000)

""")

for i in range(100000):

......a = range(1000)

h.vec.to_python(a)

I need to run a loop and the vector I record I do not know the size of before my loop starts, so I need example 1 to be working....

Any ideas, any help?

Armin