Skip to content

Instantly share code, notes, and snippets.

@rleegates
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rleegates/c305c0fec0b963257cba to your computer and use it in GitHub Desktop.
Save rleegates/c305c0fec0b963257cba to your computer and use it in GitHub Desktop.
Run GC at intervals
function doSomethingOften(n::Int64)
intv = 1000
try
gc_disable()
for i = 1:n
doSomething()
if i == intv
gc()
end
end
gc_enable()
finally
gc_enable()
end
return nothing
end
@ivarne
Copy link

ivarne commented Dec 9, 2014

The catch should probably be finally.

@rleegates
Copy link
Author

Yes, that's true, however, it still leaks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment