godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.57k stars 21.09k forks source link

Memory "leak" when writing compressed files #66802

Open BimDav opened 2 years ago

BimDav commented 2 years ago

Godot version

3.5.1-stable

System information

MacOS, M2

Issue description

When writing to a file after using open_compressed(), the memory usage increases. If the file is open using open(), memory usage is constant. This is probably not a memory leak, there should just be a way to periodically free the buffer used for compression. Using flush() periodically does not solve the issue.

Steps to reproduce

Open a file using open_compressed and write to it in _process(), for example

Minimal reproduction project

test_compression.zip

bruvzg commented 2 years ago

This is probably not a memory leak, there should just be a way to periodically free the buffer used for compression.

BimDav commented 2 years ago
  • open_compressed (for write) creates a memory buffer and will only compress and write to file when it is closed.

Good to know! Is there (should there be) a way to use flush() to compress and write to file on demand?

bruvzg commented 2 years ago

Is there (should there be) a way to use flush() to compress and write to file on demand?

No, compressed file can be written and read at arbitrary position, and it won't work with on demand compression (in this case data can be only appended at the end).