{"action":"opened","issue":{"url":"https://api.github.com/repos/ReadyTalk/avian/issues/447","labels_url":"https://api.github.com/repos/ReadyTalk/avian/issues/447/labels{/name}","comments_url":"https://api.github.com/repos/ReadyTalk/avian/issues/447/comments","events_url":"https://api.github.com/repos/ReadyTalk/avian/issues/447/events","html_url":"https://github.com/ReadyTalk/avian/issues/447","id":95632879,"number":447,"title":"Possible leak in compile function","user":{"login":"mretallack","id":5657057,"avatar_url":"https://avatars.githubusercontent.com/u/5657057?v=3","gravatar_id":"","url":"https://api.github.com/users/mretallack","html_url":"https://github.com/mretallack","followers_url":"https://api.github.com/users/mretallack/followers","following_url":"https://api.github.com/users/mretallack/following{/other_user}","gists_url":"https://api.github.com/users/mretallack/gists{/gist_id}","starred_url":"https://api.github.com/users/mretallack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mretallack/subscriptions","organizations_url":"https://api.github.com/users/mretallack/orgs","repos_url":"https://api.github.com/users/mretallack/repos","events_url":"https://api.github.com/users/mretallack/events{/privacy}","received_events_url":"https://api.github.com/users/mretallack/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-17T10:42:10Z","updated_at":"2015-07-17T10:42:10Z","closed_at":null,"body":"Hi, \r\n\r\nI have been performing a valgrind check on the avian jvm and I think I may of found a leak in the compile.cpp - compile function. \r\n\r\nIt appears that stackMap is allocated and then passed to the Frame class, but is not free'ed. I have included a patch to show the changes that I have done. This appears to stop valgrind reporting the issue, however I do not feel that I understand the code enough to say that this is a problem and that the fix is correct. \r\n\r\nThanks\r\nMark Retallack\r\n\r\n```\r\nIndex: avian/src/compile.cpp\r\n===================================================================\r\n--- avian.orig/src/compile.cpp\r\n+++ avian/src/compile.cpp\r\n@@ -7030,9 +7030,9 @@ void compile(MyThread* t, Context* conte\r\n \r\n             c->restoreState(state);\r\n \r\n-            ir::Type* stackMap = (ir::Type*)malloc(\r\n+            ir::Type* stackMap2 = (ir::Type*)malloc(\r\n                 sizeof(ir::Type) * context->method->code()->maxStack());\r\n-            Frame frame2(&frame, stackMap);\r\n+            Frame frame2(&frame, stackMap2);\r\n \r\n             unsigned end = duplicatedBaseIp + exceptionHandlerEnd(eh);\r\n             if (exceptionHandlerIp(eh) >= static_cast<unsigned>(start)\r\n@@ -7053,6 +7053,7 @@ void compile(MyThread* t, Context* conte\r\n             context->eventLog.append(PopContextEvent);\r\n \r\n             eventIndex = calculateFrameMaps(t, context, 0, eventIndex, 0);\r\n+            free(stackMap2);\r\n           }\r\n         }\r\n       }\r\n```\r\n\r\n"}}