[Numpy-discussion] creating a Numeric array from a numpy array LEAKS memory

2008-10-24 Thread Jose Borreguero
Dear numpy users,

I need to pass a Numeric array to some oldie code from a numpy array. I
decided to go like this:

for i in range(BIGNUMER):
my_numpy_array=grabArray(i)
na=Numeric.array( my_numpy_array, Numeric.Float)
oldie_code(na)

The constructor line:
na=Numeric.array( my_numpy_array, Numeric.Float)
does leak memory.

Is there a way to pass the Numeric array to oldie_code without the leaks?

Regards,
-- 
Jose M. Borreguero
Postdoctoral Associate
Oak Ridge National Laboratory
P.O. Box 2008, M.S. 6164
Oak Ridge, TN 37831
phone: 865-241-3071 fax: 865-576-5491
Email: [EMAIL PROTECTED]
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] creating a Numeric array from a numpy array LEAKS memory

2008-10-24 Thread Travis E. Oliphant
Jose Borreguero wrote:
 Dear numpy users,

 I need to pass a Numeric array to some oldie code from a numpy array. 
 I decided to go like this:

 for i in range(BIGNUMER):
 my_numpy_array=grabArray(i)
 na=Numeric.array( my_numpy_array, Numeric.Float)
 oldie_code(na)

 The constructor line:
 na=Numeric.array( my_numpy_array, Numeric.Float)
 does leak memory.

 Is there a way to pass the Numeric array to oldie_code without the leaks?
This should work without memory leaks, but there may be a bug in NumPy 
or Numeric.

Which version of Numeric and NumPy do you have?

-Travis

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] creating a Numeric array from a numpy array LEAKS memory

2008-10-24 Thread Jose Borreguero
numpy 1.1.0 (from /usr/lib/python2.4/site-packages/numpy/version.py)
Numeric 24.2 (from
/usr/lib/python2.4/site-packages/Numeric/numeric_version.py)

I also tried with an intermediate list, but got the same result:
*mylist=list(my_numpy_array)
na=Numeric.array( mylist, Numeric.Float)*
I don't have memory leaks if I use something like:
*mylist=[0.0]*BIGNUMBER*
*na=Numeric.array( mylist, Numeric.Float)*

-Jose

On Fri, Oct 24, 2008 at 1:54 PM, Travis E. Oliphant
[EMAIL PROTECTED]wrote:

 Jose Borreguero wrote:
  Dear numpy users,
 
  I need to pass a Numeric array to some oldie code from a numpy array.
  I decided to go like this:
 
  for i in range(BIGNUMER):
  my_numpy_array=grabArray(i)
  na=Numeric.array( my_numpy_array, Numeric.Float)
  oldie_code(na)
 
  The constructor line:
  na=Numeric.array( my_numpy_array, Numeric.Float)
  does leak memory.
 
  Is there a way to pass the Numeric array to oldie_code without the leaks?
 This should work without memory leaks, but there may be a bug in NumPy
 or Numeric.

 Which version of Numeric and NumPy do you have?

 -Travis

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion




-- 
Jose M. Borreguero
Postdoctoral Associate
Oak Ridge National Laboratory
P.O. Box 2008, M.S. 6164
Oak Ridge, TN 37831
phone: 865-241-3071 fax: 865-576-5491
Email: [EMAIL PROTECTED]
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] creating a Numeric array from a numpy array LEAKS memory

2008-10-24 Thread Jose Borreguero
My bad. Using the intermediate list does *not* leak.
Still, the original problems stays. Can anyone run the following code in
their machine and see if they have leaks?
Maybe it only happens to me :(*

import numpy,Numeric
big=1000
na=numpy.array([0.0,])
for i in range(big):
Na=Numeric.array(na,Numeric.Float)*

-Jose

On Fri, Oct 24, 2008 at 2:16 PM, Jose Borreguero [EMAIL PROTECTED]wrote:

 numpy 1.1.0 (from /usr/lib/python2.4/site-packages/numpy/version.py)
 Numeric 24.2 (from
 /usr/lib/python2.4/site-packages/Numeric/numeric_version.py)

 I also tried with an intermediate list, but got the same result:
 *mylist=list(my_numpy_array)
 na=Numeric.array( mylist, Numeric.Float)*
 I don't have memory leaks if I use something like:
 *mylist=[0.0]*BIGNUMBER*
 *na=Numeric.array( mylist, Numeric.Float)*

 -Jose


 On Fri, Oct 24, 2008 at 1:54 PM, Travis E. Oliphant 
 [EMAIL PROTECTED] wrote:

 Jose Borreguero wrote:
  Dear numpy users,
 
  I need to pass a Numeric array to some oldie code from a numpy array.
  I decided to go like this:
 
  for i in range(BIGNUMER):
  my_numpy_array=grabArray(i)
  na=Numeric.array( my_numpy_array, Numeric.Float)
  oldie_code(na)
 
  The constructor line:
  na=Numeric.array( my_numpy_array, Numeric.Float)
  does leak memory.
 
  Is there a way to pass the Numeric array to oldie_code without the
 leaks?
 This should work without memory leaks, but there may be a bug in NumPy
 or Numeric.

 Which version of Numeric and NumPy do you have?

 -Travis

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion




 --
 Jose M. Borreguero
 Postdoctoral Associate
 Oak Ridge National Laboratory
 P.O. Box 2008, M.S. 6164
 Oak Ridge, TN 37831
 phone: 865-241-3071 fax: 865-576-5491
 Email: [EMAIL PROTECTED]




-- 
Jose M. Borreguero
Postdoctoral Associate
Oak Ridge National Laboratory
P.O. Box 2008, M.S. 6164
Oak Ridge, TN 37831
phone: 865-241-3071 fax: 865-576-5491
Email: [EMAIL PROTECTED]
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] creating a Numeric array from a numpy array LEAKS memory

2008-10-24 Thread Pauli Virtanen
Fri, 24 Oct 2008 14:39:59 -0400, Jose Borreguero wrote:

 My bad. Using the intermediate list does *not* leak. Still, the original
 problems stays. Can anyone run the following code in their machine and
 see if they have leaks? Maybe it only happens to me :(*
 
 import numpy,Numeric
 big=1000
 na=numpy.array([0.0,])
 for i in range(big):
 Na=Numeric.array(na,Numeric.Float)*

Yep, leaks also here: (Numeric 24.2, numpy 1.2.0)

import sys, numpy, Numeric
na = numpy.array([0.0])
for i in xrange(100):
foo = Numeric.array(na, Numeric.Float)
print sys.getrefcount(na)

The getrefcount prints 102, so it seems like there's a refcount error 
somewhere. But

na = numpy.array([0.0])
for i in xrange(100):
foo = numpy.array(na, numpy.float_)
print sys.getrefcount(na)

refcounts correctly.

-- 
Pauli Virtanen

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] creating a Numeric array from a numpy array LEAKS memory

2008-10-24 Thread Peter
On Fri, Oct 24, 2008 at 7:52 PM, Pauli Virtanen [EMAIL PROTECTED] wrote:
 Yep, leaks also here: (Numeric 24.2, numpy 1.2.0)

import sys, numpy, Numeric
na = numpy.array([0.0])
for i in xrange(100):
foo = Numeric.array(na, Numeric.Float)
print sys.getrefcount(na)

 The getrefcount prints 102, so it seems like there's a refcount error
 somewhere.

Same leak here using Numeric 24.2 and numpy 1.0.1 on Linux.

 But

na = numpy.array([0.0])
for i in xrange(100):
foo = numpy.array(na, numpy.float_)
print sys.getrefcount(na)

 refcounts correctly.

Also fine.  And for the record using the intermediate list also works for me:

import sys, numpy, Numeric
na = numpy.array([0.0])
na_list = list(na)
for i in xrange(100):
 foo = Numeric.array(na_list, Numeric.Float)
print sys.getrefcount(na)

Peter
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion