Last active
December 14, 2015 00:39
-
-
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()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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