#35 glGetDoublev memory leak

GL (74)

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!


  • Mike C. Fletcher

    Logged In: YES

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

  • Mike C. Fletcher

    Logged In: YES

    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?

  • Mike C. Fletcher

    • priority: 5 --> 7
    • assigned_to: twburton --> nobody
  • Mike C. Fletcher

    • milestone: --> v2.0
    • status: open --> closed-fixed
  • Mike C. Fletcher

    Logged In: YES

    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?


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks