[Numpy-discussion] Deleting arrays.

Konrad Hinsen hinsen at cnrs-orleans.fr
Wed Feb 25 02:53:01 EST 2004


On Tuesday 24 February 2004 22:10, Andrea Riciputi wrote:

> anymore. These arrays have been created on the C side of my code and
> then copied (actually linked via PyArray_FromDimsAndData) to Numeric
> arrays. How can I release these arrays and get back memory in order to
> be able to start the next run?

I am not aware of any clean way. A hack that might help you out is

   array->flags |= OWN_DATA;

The data will then be freed when the array is released. However, there are a 
few caveats:
1) This is not documented.
2) It works only if the data was allocated by the same memory manager that
   is used by NumPy.
3) You have to make sure that no other code keeps a reference to the data.

If modifying the C code is an option, then it is probably the better one.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------





More information about the NumPy-Discussion mailing list