{"action":"created","issue":{"url":"https://api.github.com/repos/numba/numba/issues/1702","repository_url":"https://api.github.com/repos/numba/numba","labels_url":"https://api.github.com/repos/numba/numba/issues/1702/labels{/name}","comments_url":"https://api.github.com/repos/numba/numba/issues/1702/comments","events_url":"https://api.github.com/repos/numba/numba/issues/1702/events","html_url":"https://github.com/numba/numba/issues/1702","id":132929649,"number":1702,"title":"Memory leak in np.linalg.inv","user":{"login":"MatthieuDartiailh","id":4481740,"avatar_url":"https://avatars.githubusercontent.com/u/4481740?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthieuDartiailh","html_url":"https://github.com/MatthieuDartiailh","followers_url":"https://api.github.com/users/MatthieuDartiailh/followers","following_url":"https://api.github.com/users/MatthieuDartiailh/following{/other_user}","gists_url":"https://api.github.com/users/MatthieuDartiailh/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthieuDartiailh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthieuDartiailh/subscriptions","organizations_url":"https://api.github.com/users/MatthieuDartiailh/orgs","repos_url":"https://api.github.com/users/MatthieuDartiailh/repos","events_url":"https://api.github.com/users/MatthieuDartiailh/events{/privacy}","received_events_url":"https://api.github.com/users/MatthieuDartiailh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-11T09:52:46Z","updated_at":"2016-02-11T10:13:46Z","closed_at":null,"body":"Numba implementation of np.linalg.inv is leaking memory. The following script demonstrates it (and check that np.dot does not).\r\n\r\nI am willing to help fix this, and I would appreciate any pointers in where to look at and what to look for.\r\n\r\n``` python\r\n# -*- coding: utf-8 -*-\r\nimport gc\r\nimport tracemalloc\r\nimport numpy as np\r\nfrom numba import njit\r\n\r\n\r\n@njit\r\ndef dot():\r\n    a = np.ones((100, 100))\r\n    c = np.dot(a, a)\r\n    return c\r\n\r\ndot()\r\n\r\n\r\n@njit\r\ndef inv():\r\n    a = np.diag(np.linspace(1, 2, 100))\r\n    c = np.linalg.inv(a)\r\n    return c\r\n\r\ninv()\r\n\r\ntracemalloc.start()\r\n\r\nprint('Dot')\r\nfor i in range(100):\r\n    d = dot()\r\n    print(tracemalloc.get_traced_memory())\r\n\r\nprint('Inv')\r\nfor i in range(100):\r\n    d = inv()\r\n    print(tracemalloc.get_traced_memory())\r\n\r\ngc.collect()\r\nprint(tracemalloc.get_traced_memory())\r\n\r\n```\r\n\r\nLeads to : \r\n```\r\nDot\r\n(80416, 160416)\r\n(80448, 240624)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\n(80448, 240656)\r\nInv\r\n(132944, 293152)\r\n(265368, 345472)\r\n(397792, 477896)\r\n(530216, 610320)\r\n(662640, 742744)\r\n(795064, 875168)\r\n(927488, 1007592)\r\n(1059912, 1140016)\r\n(1192336, 1272440)\r\n(1324760, 1404864)\r\n(1457184, 1537288)\r\n(1589608, 1669712)\r\n(1722032, 1802136)\r\n(1854456, 1934560)\r\n(1986880, 2066984)\r\n(2119304, 2199408)\r\n(2251728, 2331832)\r\n(2384152, 2464256)\r\n(2516576, 2596680)\r\n(2649000, 2729104)\r\n(2781424, 2861528)\r\n(2913848, 2993952)\r\n(3046272, 3126376)\r\n(3178696, 3258800)\r\n(3311120, 3391224)\r\n(3443544, 3523648)\r\n(3575968, 3656072)\r\n(3708392, 3788496)\r\n(3840816, 3920920)\r\n(3973240, 4053344)\r\n(4105664, 4185768)\r\n(4238088, 4318192)\r\n(4370512, 4450616)\r\n(4502936, 4583040)\r\n(4635360, 4715464)\r\n(4767784, 4847888)\r\n(4900208, 4980312)\r\n(5032632, 5112736)\r\n(5165056, 5245160)\r\n(5297480, 5377584)\r\n(5429904, 5510008)\r\n(5562328, 5642432)\r\n(5694752, 5774856)\r\n(5827176, 5907280)\r\n(5959600, 6039704)\r\n(6092024, 6172128)\r\n(6224448, 6304552)\r\n(6356872, 6436976)\r\n(6489296, 6569400)\r\n(6621720, 6701824)\r\n(6754144, 6834248)\r\n(6886568, 6966672)\r\n(7018992, 7099096)\r\n(7151416, 7231520)\r\n(7283840, 7363944)\r\n(7416264, 7496368)\r\n(7548688, 7628792)\r\n(7681112, 7761216)\r\n(7813536, 7893640)\r\n(7945960, 8026064)\r\n(8078384, 8158488)\r\n(8210808, 8290912)\r\n(8343232, 8423336)\r\n(8475656, 8555760)\r\n(8608080, 8688184)\r\n(8740504, 8820608)\r\n(8872928, 8953032)\r\n(9005352, 9085456)\r\n(9137776, 9217880)\r\n(9270200, 9350304)\r\n(9402624, 9482728)\r\n(9535048, 9615152)\r\n(9667472, 9747576)\r\n(9799896, 9880000)\r\n(9932320, 10012424)\r\n(10064744, 10144848)\r\n(10197168, 10277272)\r\n(10329592, 10409696)\r\n(10462016, 10542120)\r\n(10594440, 10674544)\r\n(10726864, 10806968)\r\n(10859288, 10939392)\r\n(10991712, 11071816)\r\n(11124136, 11204240)\r\n(11256560, 11336664)\r\n(11388984, 11469088)\r\n(11521408, 11601512)\r\n(11653832, 11733936)\r\n(11786256, 11866360)\r\n(11918680, 11998784)\r\n(12051104, 12131208)\r\n(12183528, 12263632)\r\n(12315952, 12396056)\r\n(12448376, 12528480)\r\n(12580800, 12660904)\r\n(12713224, 12793328)\r\n(12845648, 12925752)\r\n(12978072, 13058176)\r\n(13110496, 13190600)\r\n(13242920, 13323024)\r\n(13242888, 13323024)\r\n```"},"comment":{"url":"https://api.github.com/repos/numba/numba/issues/comments/182791448","html_url":"https://github.com/numba/numba/issues/1702#issuecomment-182791448","issue_url":"https://api.github.com/repos/numba/numba/issues/1702","id":182791448,"user":{"login":"MatthieuDartiailh","id":4481740,"avatar_url":"https://avatars.githubusercontent.com/u/4481740?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthieuDartiailh","html_url":"https://github.com/MatthieuDartiailh","followers_url":"https://api.github.com/users/MatthieuDartiailh/followers","following_url":"https://api.github.com/users/MatthieuDartiailh/following{/other_user}","gists_url":"https://api.github.com/users/MatthieuDartiailh/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthieuDartiailh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthieuDartiailh/subscriptions","organizations_url":"https://api.github.com/users/MatthieuDartiailh/orgs","repos_url":"https://api.github.com/users/MatthieuDartiailh/repos","events_url":"https://api.github.com/users/MatthieuDartiailh/events{/privacy}","received_events_url":"https://api.github.com/users/MatthieuDartiailh/received_events","type":"User","site_admin":false},"created_at":"2016-02-11T10:13:46Z","updated_at":"2016-02-11T10:13:46Z","body":"The same holds for work. How do I deallocate the memory ? "}}