API/C memory mananegemnt problem

Discussion in 'Python' started by fumana@lambrate.inaf.it, Mar 10, 2006.

  1. Guest

    Hi everybody,
    I have a problem with Python/C API and memory management.

    I'm using
    Python 2.3.5 (#1, Jan 4 2006, 16:44:27)
    [GCC 4.0.2 20050901 (prerelease) (SUSE Linux)] on linux2

    In my C-module I have a loop like this:
    ***********************************************

    int size=10000000;

    output=(double *) calloc(size, sizeof(double));

    py_output=PyList_New(0);

    for(i=0; i<size; i++){
    tmp=PyFloat_FromDouble(output);
    PyList_Append(py_output, tmp);
    }

    free(outout);

    return py_output;

    ***********************************************

    It returns to python module a (very large) list.

    Problem: when I delete the list in python module (with python del statement)
    not all memory is relased.

    It look like all 10000000 tmp PyFloat allocated in C code
    remain stored in memory.

    Somebody can help me?

    Thanks.

    marco
    , Mar 10, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shlomo Anglister
    Replies:
    1
    Views:
    391
    Default User
    Aug 2, 2004
  2. Praveen, Tayal (IE10)
    Replies:
    0
    Views:
    356
    Praveen, Tayal (IE10)
    Mar 17, 2005
  3. Marco Fumana

    API/C memory mananegemnt problem

    Marco Fumana, Mar 10, 2006, in forum: Python
    Replies:
    0
    Views:
    298
    Marco Fumana
    Mar 10, 2006
  4. Tim Peters

    Re: API/C memory mananegemnt problem

    Tim Peters, Mar 11, 2006, in forum: Python
    Replies:
    6
    Views:
    291
    Alex Martelli
    Mar 12, 2006
  5. John123

    Profiling API or Membership API

    John123, Oct 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    356
    John123
    Oct 20, 2006
Loading...

Share This Page