{"action":"created","issue":{"url":"https://api.github.com/repos/znc/znc/issues/1017","labels_url":"https://api.github.com/repos/znc/znc/issues/1017/labels{/name}","comments_url":"https://api.github.com/repos/znc/znc/issues/1017/comments","events_url":"https://api.github.com/repos/znc/znc/issues/1017/events","html_url":"https://github.com/znc/znc/issues/1017","id":98953683,"number":1017,"title":"Memory Leak","user":{"login":"stevesbrain","id":6745111,"avatar_url":"https://avatars.githubusercontent.com/u/6745111?v=3","gravatar_id":"","url":"https://api.github.com/users/stevesbrain","html_url":"https://github.com/stevesbrain","followers_url":"https://api.github.com/users/stevesbrain/followers","following_url":"https://api.github.com/users/stevesbrain/following{/other_user}","gists_url":"https://api.github.com/users/stevesbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/stevesbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevesbrain/subscriptions","organizations_url":"https://api.github.com/users/stevesbrain/orgs","repos_url":"https://api.github.com/users/stevesbrain/repos","events_url":"https://api.github.com/users/stevesbrain/events{/privacy}","received_events_url":"https://api.github.com/users/stevesbrain/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-04T12:13:13Z","updated_at":"2015-08-04T20:13:55Z","closed_at":null,"body":"Hey guys,\r\n\r\nA little while ago I mentioned in #znc about a memory leak problem I was experiencing. What was happening was that I'd start up ZNC (1.6), and about two weeks later, I'd be at my servers comfortable memory limit (gone up from 50% -> 93%) after steadily rising during its running.\r\n\r\nI upgraded from ZNC 1.4 on the same server, which didn't have this issue at all. The only difference between the two version is that I \"upgraded\" from znc-push's C branch to the actively developed Python branch. This meant I needed to also compile ZNC 1.6 with modpython (which I didn't have previously). This, on one hand, makes me suspect either *modpython* or *push* as the responsible parties. However, doing a ```/msg *status unloadmod push; /msg *status unloadmod modpython``` does not reduce memory usage at all.\r\n\r\nHaving said that, I haven't tried starting ZNC with both of these disabled - only unloading them and reloading them (as two separate tests). Aside from these, the only other modules I use are \"core\" modules. I can provide a breakdown if need be.\r\n\r\nAs for memory usage profiling, I've run ZNC under massif for the last few days, and each of the different functions do not grow (significantly) in usage over time, except one. The details of which are listed below:\r\n\r\n![Massif Visualiser Data](http://i.imgur.com/fiuhjnC.png?1)\r\n\r\nThe text of the largest snapshot, nested, are as follows:\r\n```bash\r\n0x593F207: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)\r\n0x594092F: char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)\r\n0x59409EB: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)\r\n0x8774845: SWIG_AsPtr_std_string(_object*, CString**) (in /usr/local/lib/znc/modpython/_znc_core.so)\r\n0x87F51B5: _wrap_CIRCNetwork_ExpandString (in /usr/local/lib/znc/modpython/_znc_core.so)\r\n0x784A201: PyEval_EvalFrameEx (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x7973514: PyEval_EvalCodeEx (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x784A56B: PyEval_EvalFrameEx (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x784C943: PyEval_EvalFrameEx (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x7973B44: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x7888456: PyObject_Call (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x78B181B: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x7888456: PyObject_Call (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x7868ADF: PyObject_CallMethodObjArgs (in /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0)\r\n0x75227FB: CPyModule::OnChanMsg(CNick&, CChan&, CString&) (in /usr/local/lib/znc/modpython.so)\r\n0x4BBADE: CModules::OnChanMsg(CNick&, CChan&, CString&) (in /usr/local/bin/znc)\r\n0x47EDA8: CIRCSock::OnChanMsg(CNick&, CString const&, CString&) (in /usr/local/bin/znc)\r\n0x48F4A1: CIRCSock::ReadLine(CString const&) (in /usr/local/bin/znc)\r\n0x4411DE: Csock::PushBuff(char const*, unsigned long, bool) (in /usr/local/bin/znc)\r\n0x44A50C: CSocketManager::Loop() (in /usr/local/bin/znc)\r\n0x4483BF: CSocketManager::DynamicSelectLoop(unsigned long, unsigned long, long) (in /usr/local/bin/znc)\r\n0x45B56E: CZNC::Loop() (in /usr/local/bin/znc)\r\n0x430369: main (in /usr/local/bin/znc)\r\n```\r\n\r\nThis, to me, certainly makes it look more Python-related, but I'd love to help track it down if I can in any way. Keep in mind, not a programmer by any means - just love the project :smile: \r\n\r\nJust for completeness, the rest of the expanded info is below in the screenshots:\r\n\r\n![Massif 2](http://i.imgur.com/CSUN9G7.png?1)\r\n![Massif 3](http://i.imgur.com/NAX4rh1.png?1)\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/25353357-memory-leak?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/znc/znc/issues/comments/127743077","html_url":"https://github.com/znc/znc/issues/1017#issuecomment-127743077","issue_url":"https://api.github.com/repos/znc/znc/issues/1017","id":127743077,"user":{"login":"DarthGandalf","id":325092,"avatar_url":"https://avatars.githubusercontent.com/u/325092?v=3","gravatar_id":"","url":"https://api.github.com/users/DarthGandalf","html_url":"https://github.com/DarthGandalf","followers_url":"https://api.github.com/users/DarthGandalf/followers","following_url":"https://api.github.com/users/DarthGandalf/following{/other_user}","gists_url":"https://api.github.com/users/DarthGandalf/gists{/gist_id}","starred_url":"https://api.github.com/users/DarthGandalf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DarthGandalf/subscriptions","organizations_url":"https://api.github.com/users/DarthGandalf/orgs","repos_url":"https://api.github.com/users/DarthGandalf/repos","events_url":"https://api.github.com/users/DarthGandalf/events{/privacy}","received_events_url":"https://api.github.com/users/DarthGandalf/received_events","type":"User","site_admin":false},"created_at":"2015-08-04T20:13:55Z","updated_at":"2015-08-04T20:13:55Z","body":"Thanks @stevesbrain for detailed info!\r\nI reproduced it, with the following minimal python module:\r\n```py\r\nimport znc\r\n\r\ns = \"aaaaaaaaaaaaaa\"\r\nfor y in range(10):\r\n    s += s\r\n\r\nclass ptest(znc.Module):\r\n    def OnLoad(self, args, msg):\r\n        while True:\r\n            self.GetNetwork().SetRealName(s)\r\n```"}}