{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/11698","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/11698/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/11698/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/11698/events","html_url":"https://github.com/JuliaLang/julia/issues/11698","id":87909602,"number":11698,"title":"cholfact leaks memory","user":{"login":"KristofferC","id":1282691,"avatar_url":"https://avatars.githubusercontent.com/u/1282691?v=3","gravatar_id":"","url":"https://api.github.com/users/KristofferC","html_url":"https://github.com/KristofferC","followers_url":"https://api.github.com/users/KristofferC/followers","following_url":"https://api.github.com/users/KristofferC/following{/other_user}","gists_url":"https://api.github.com/users/KristofferC/gists{/gist_id}","starred_url":"https://api.github.com/users/KristofferC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KristofferC/subscriptions","organizations_url":"https://api.github.com/users/KristofferC/orgs","repos_url":"https://api.github.com/users/KristofferC/repos","events_url":"https://api.github.com/users/KristofferC/events{/privacy}","received_events_url":"https://api.github.com/users/KristofferC/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-06-13T02:28:49Z","updated_at":"2015-06-13T17:44:06Z","closed_at":null,"body":"After reading [this post](https://groups.google.com/forum/#!topic/julia-users/4aSWQTJPFKc) on the mailing list I started bisecting and found that https://github.com/JuliaLang/julia/commit/2ecb6d5c58e8 introduced a memory leak in `cholfact`. It is a quite big commit but my guess is that some \"finalizer command\" is not sent to cholmod for it to release its internal memory.\r\n\r\nThe test script I used is the same one as in the mailing list:\r\n\r\n```julia\r\nfunction f(n)\r\n  A = speye(n)\r\n  fact = cholfact(A)\r\n  for i=1:1000\r\n    fact = cholfact(A)\r\n  end\r\nend\r\n```\r\n\r\nThe memory allocations are not seen by `@time` so some external program like `htop` can be used. This is the status after running the test script a couple of times for `n = 10_000`:\r\n\r\n![screenshot from 2015-06-13 04 25 59](https://cloud.githubusercontent.com/assets/1282691/8142661/52f5a70c-1184-11e5-88d6-d7e9ccaccaf6.png)\r\n\r\nThe memory is not reclaimed until Julia is exited.\r\n\r\nCC @andreasnoack "},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/111736199","html_url":"https://github.com/JuliaLang/julia/issues/11698#issuecomment-111736199","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/11698","id":111736199,"user":{"login":"carnaval","id":5307791,"avatar_url":"https://avatars.githubusercontent.com/u/5307791?v=3","gravatar_id":"","url":"https://api.github.com/users/carnaval","html_url":"https://github.com/carnaval","followers_url":"https://api.github.com/users/carnaval/followers","following_url":"https://api.github.com/users/carnaval/following{/other_user}","gists_url":"https://api.github.com/users/carnaval/gists{/gist_id}","starred_url":"https://api.github.com/users/carnaval/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carnaval/subscriptions","organizations_url":"https://api.github.com/users/carnaval/orgs","repos_url":"https://api.github.com/users/carnaval/repos","events_url":"https://api.github.com/users/carnaval/events{/privacy}","received_events_url":"https://api.github.com/users/carnaval/received_events","type":"User","site_admin":false},"created_at":"2015-06-13T17:44:05Z","updated_at":"2015-06-13T17:44:05Z","body":"This is a lack of memory pressure. The gc has no way to know how much memory was allocated so it prefers just doing nothing. You can use the jl_gc_counted_* family to apply memory pressure when allocating using an external library which will be freed by a finalizer. See bigints in base for an example.\r\n\r\nIts fine if you only use an approximation of how much memory was allocated but be careful to match the counted_alloc with a counted_free of the same size."}}