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

Free memory on MemoryFS.close #308

Closed
mostafa opened this issue Jul 6, 2019 · 2 comments · Fixed by #313
Closed

Free memory on MemoryFS.close #308

mostafa opened this issue Jul 6, 2019 · 2 comments · Fixed by #313

Comments

@mostafa
Copy link

mostafa commented Jul 6, 2019

Steps to reproduce:

  1. Run this piece of code in your favorite REPL.
from fs.memoryfs import MemoryFS

mem_fs = MemoryFS()
with open('large_binary_file', 'rb') as f:
	mem_fs.upload('/large_binary_file', f)
mem_fs.close()
  1. Watch python process before and after running this script.
  2. The memory is there and the files are not removed.
  3. Run del mem_fs and it immediately claims back the memory.
@mostafa mostafa changed the title Bug: Memory is not cleaned after MemoryFS is closed Bug: Memory is not released after MemoryFS is closed Jul 12, 2019
@willmcgugan
Copy link
Member

The close method isn't obliged to free up memory when called. Only destruction of the object can guarantee that. That said, freeing up memory on close is probably good idea.

@willmcgugan willmcgugan self-assigned this Jul 24, 2019
@willmcgugan willmcgugan changed the title Bug: Memory is not released after MemoryFS is closed Free memory on MemoryFS.close Jul 24, 2019
@mostafa
Copy link
Author

mostafa commented Jul 25, 2019

Since you now longer have access to that part of the memory, freeing it up would help reduce memory footprint of some applications.

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

Successfully merging a pull request may close this issue.

2 participants