Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge memory usage #71

Open
RobertCsordas opened this issue Aug 16, 2016 · 1 comment
Open

Huge memory usage #71

RobertCsordas opened this issue Aug 16, 2016 · 1 comment

Comments

@RobertCsordas
Copy link

I'm not sure if it is a bug, but the following code eats up all my memory (12 gigabytes) and I don't understand why:

local threads=require 'threads'
th=threads.Threads(8);
while true do
    th:addjob(function ()
        collectgarbage()
        print("Thread: "..(collectgarbage("count")/1024).." Mbytes")
        local d=torch.rand(10000,10000) --should be 762Mbytes
        collectgarbage()    
        return d
    end)
    print("Main: "..(collectgarbage("count")/1024).." Mbytes")
    th:dojob()
    collectgarbage()
end

The amount of memory used depends on the number of threads (about 1.6Gbyte/thread). The garbage collector shows ~1 Mbytes of memory for both thread and main block, but if I check it out with htop, I can see that it eats up all the memory and gets killed by the kernel. Shouldn't be about 800Mbytes of memory enough for this code to run? Should't the dojob() free the memory required by the thread?

This is only a toy example, I want to create a loader that fetches and prepossesses data in the background, but it uses enormous amount of memory, although the useful data fits in a much smaller space.

@alimousazy
Copy link

Hi @xdever ,

I ran the same code but I haven't had the issue. for how long should I run the code ?

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants