Skip to content

Instantly share code, notes, and snippets.

@soumith
Last active December 14, 2015 00:39
Show Gist options
  • Save soumith/5000774 to your computer and use it in GitHub Desktop.
Save soumith/5000774 to your computer and use it in GitHub Desktop.
torch seems to have a memleak in this case, even though you'd expect it to not, with the collectgarbage()
require 'image'
local memTestClass = torch.class('image.memTestClass')
function memTestClass:__newindex__(key, value)
if type(key) == 'number' then
return 1 -- do this so that rawset isn't called anyways, stupid of me to miss this
else rawset(self, key, value) end
end
function testMemory()
n = 50000
data=image.memTestClass()
for i=1,n do
local img = image.lena()
data[i] = img
collectgarbage()
end
end
testMemory()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment