#3 jack.get_ports() memory leak

v0.6
closed
None
5
2013-11-07
2012-12-17
John Smith
No

This code eats all memory and swap after 20 seconds.
≈ 150 MiB/second.

import jack
jack.attach('test')
jack.activate()
while True: jack.get_ports()

Discussion

  • John Smith

    John Smith - 2012-12-17

    If to insert this:
    free(jplist);

    before this:
    Py_INCREF(plist);
    return plist;

    In “get_ports” function in “pyjack.c” — 20 MiB/sec. vs. 150 MiB/sec.

     
  • John Smith

    John Smith - 2012-12-18

    I'm fixed it!
    Need replace “get_ports” function to this code:

    // Returns a list of all port names registered in the Jack system
    static PyObject* get_ports(PyObject* self, PyObject* args)
    {
    PyObject* plist;
    const char** jplist;
    int i, count = 0;

    pyjack_client_t * client = self_or_global_client(self);
    if(client->pjc == NULL) {
    PyErr_SetString(JackNotConnectedError, "Jack connection has not yet been established.");
    return NULL;
    }

    jplist = jack_get_ports(client->pjc, NULL, NULL, 0);

    if(jplist != NULL) {
    while(jplist[count] != NULL) {
    count += 1;
    }
    plist = PyList_New(count);

    for(i=0; i<count; i++) {
    PyList_SET_ITEM(plist, i, Py_BuildValue("s", jplist[i]));
    }
    } else {
    plist = PyList_New(0);
    }

    free(jplist);
    return plist;
    }

     
  • John Smith

    John Smith - 2012-12-18

    Has PyJACK repo on github (for pull requests)?

     
  • John Smith

    John Smith - 2012-12-18

    And “get_connections” method has memory leak too. Fixed version:

    static PyObject* get_connections(PyObject* self, PyObject* args)
    {
    char* pname;
    const char** jplist;
    jack_port_t* jp;
    PyObject* plist;
    int i, count = 0;

    pyjack_client_t * client = self_or_global_client(self);
    if(client->pjc == NULL) {
    PyErr_SetString(JackNotConnectedError, "Jack connection has not yet been established.");
    return NULL;
    }

    if (! PyArg_ParseTuple(args, "s", &pname))
    return NULL;

    jp = jack_port_by_name(client->pjc, pname);
    if(jp == NULL) {
    PyErr_SetString(JackError, "Bad port name.");
    return NULL;
    }

    jplist = jack_port_get_all_connections(client->pjc, jp);

    if(jplist != NULL) {
    while(jplist[count] != NULL) {
    count += 1;
    }
    plist = PyList_New(count);

    for(i=0; i<count; i++) {
    PyList_SET_ITEM(plist, i, Py_BuildValue("s", jplist[i]));
    }
    } else {
    plist = PyList_New(0);
    }

    free(jplist);
    return plist;
    }

     
  • John Smith

    John Smith - 2012-12-18

    “disconnect” method doesn't working and has memory leak 300-400 mb/s.

     
  • IOhannes m zmölnig

    • status: open --> pending
    • assigned_to: IOhannes m zmölnig
    • Group: --> v1.0_(example)
     
  • IOhannes m zmölnig

    i believe this is fixed with commits db4b87af38, e106328f6e, 6ec7dc8c82.

     
  • IOhannes m zmölnig

    • status: pending --> closed
     
  • IOhannes m zmölnig

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,7 +1,8 @@
     This code eats all memory and swap after 20 seconds.
      150 MiB/second.
    
    -import jack
    -jack.attach\('test'\)
    -jack.activate\(\)
    -while True: jack.get\_ports\(\)
    +    :::python
    +    import jack
    +    jack.attach('test')
    +    jack.activate()
    +    while True: jack.get_ports()
    
     
  • IOhannes m zmölnig

    fixed with v0.6

     

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

Sign up for the SourceForge newsletter:





No, thanks