Edgewall Software

Ticket #166: cspeedups-fix-memleak-r780.diff

File cspeedups-fix-memleak-r780.diff, 1.4 KB (added by cboos, 4 years ago)

Fix some more issues. The Py_DECREF(unicode); near line 380 seems important. Things seems to be a bit better with that patch, approx 400K increase for each request.

  • trunk/genshi/_speedups.c

     
    8787 
    8888    out = (PyUnicodeObject*) PyUnicode_FromUnicode(NULL, len); 
    8989    if (out == NULL) { 
     90        Py_DECREF((PyObject *) in); 
    9091        return NULL; 
    9192    } 
    9293 
     
    130131        inp++; 
    131132    } 
    132133 
     134    Py_DECREF((PyObject *) in); 
     135 
    133136    args = PyTuple_New(1); 
    134137    if (args == NULL) { 
    135138        Py_DECREF((PyObject *) out); 
     
    303306            return NULL; 
    304307        tmp2 = PyUnicode_Concat(tmp, other); 
    305308    } 
    306     if (tmp2 == NULL) { 
    307         Py_DECREF(tmp); 
     309    Py_DECREF(tmp); 
     310    if (tmp2 == NULL) 
    308311        return NULL; 
    309     } 
    310     Py_DECREF(tmp); 
    311312    args = PyTuple_New(1); 
    312313    if (args == NULL) { 
    313314        Py_DECREF(tmp2); 
     
    380381        if (unicode == NULL) return NULL; 
    381382        result = PyNumber_Multiply(unicode, self); 
    382383    } 
     384    Py_DECREF(unicode); 
    383385 
    384386    if (result == NULL) return NULL; 
    385387    args = PyTuple_New(1); 
     
    402404    format = PyString_FromString("<Markup %r>"); 
    403405    if (format == NULL) return NULL; 
    404406    result = PyObject_Unicode(self); 
    405     if (result == NULL) return NULL; 
     407    if (result == NULL) { 
     408        Py_DECREF(format); 
     409        return NULL; 
     410    } 
    406411    args = PyTuple_New(1); 
    407412    if (args == NULL) { 
     413        Py_DECREF(format); 
    408414        Py_DECREF(result); 
    409415        return NULL; 
    410416    }