Commit d15906e9 authored by Marius Wachtler's avatar Marius Wachtler

hidden classes: free classes of singleton type

this fixes the huge (~350MB) leak in:
for i in xrange(1000000):
    class C(object):
        pass
parent ce0a5ddd
......@@ -43,9 +43,10 @@ public:
protected:
HiddenClass(HCType type) : type(type) {}
virtual ~HiddenClass() = default;
public:
virtual ~HiddenClass() = default;
static HiddenClassSingleton* makeSingleton();
static HiddenClassNormal* makeRoot();
static HiddenClassDict* makeDictBacked();
......
......@@ -1317,6 +1317,9 @@ void HCAttrs::_clearRaw() noexcept {
auto old_attr_list = this->attr_list;
auto old_attr_list_size = hcls->attributeArraySize();
// singleton classes will not get reused so free it
if (hcls->type == HiddenClass::SINGLETON)
delete hcls;
new ((void*)this) HCAttrs(NULL);
if (old_attr_list) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment