#35 glGetDoublev memory leak

v2.0
closed-fixed
nobody
GL (74)
7
2015-04-18
2002-05-28
Anonymous
No

mvMatrix = glGetDoublev(GL_MODELVIEW_MATRIX)
This line leaks substantial amounts of memory. In my
application I had this happening on every refresh, with a
resulting leak sucking up at least 32K/sec!

Discussion

  • Test file for the leak situation

     
    Attachments
  • Logged In: YES
    user_id=34901

    Confirmed that this occurs with PyOpenGL 2.0.0.44 with
    Python 2.2.1 on Win2K. Test file now attached.

     
  • Logged In: YES
    user_id=34901

    Okay, have been looking at this, basically, there is a lot
    of macro expansion going on, but at the core, we have this
    code running:

    ( interfaceutil.inc )
    #define NUMERIC_PyObject_From(NAME, BASE, TYPECODE)\ PyObject* _PyObject_From##NAME(int nd, int* dims, BASE*
    data, int own)\ {\ if (PyArray_API)\ {\ BASE* my;\ int i, l;\ \ if (own) my = data; else\ {\ for (i = 0, l = 1; i < nd; i++) l *= dims[i];\ my = PyMem_New(BASE, l);\ memcpy(my, data, sizeof(BASE)*l);\ }\ \ return PyArray_FromDimsAndData(nd, dims, TYPECODE,
    (char*)my);\ }\ return NonNumeric_PyObject_From##NAME(nd, dims, data, own);\ }

    Now, PyArray_FromDimsAndData says that it takes static
    memory that can never be released, so I'm thinking that it
    doesn't free the memory pool when (PyMem_Free) when the
    array object is deleted. As a result, there's a leak every
    time we create a return-value array (of any type).

    Not sure what we should do. Could just use PyArray_FromDims
    and then manually copy the data from the source, but that
    seems a little... inelegant. Suggestions?

     
    • priority: 5 --> 7
    • assigned_to: twburton --> nobody
     
    • milestone: --> v2.0
    • status: open --> closed-fixed
     
  • Logged In: YES
    user_id=34901

    Have just checked in a fix for this, appears to address the
    problem. It uses PyArray_FromDims and then manually copies
    the data from the source (as described earlier). Test no
    longer leaks memory.

     
  • funkeypigeon
    funkeypigeon
    2015-04-18

    I have the same problem you started off with. How do I fix it?