Hello, like the title says, seems like calls to love.math.compress/decompress leak about ~200kb of memory (or maybe even more), independent of the compression algorithm. (I've tried lz4 and zlib so far, with different compression levels)
I'm writing savefiles to disk, and if I compress the written data with love.math.compress, then I get memory leaks. If I don't - no memory leak occurs. Additionally, this leak occurs even without writing the compressed output to a file. just having a for i = 1, 100 do love.math.compress(data, "compressionFormat", compressionLevel) end will leak 50 megabytes of memory at the end of the iteration cycle.
Edit 1: amount of leaked memory seems to depend on size of the string for compression passed into the love.math.compress/decompress call.
[0.10.2] love.math.compress/decompress seems to be leaking memory
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: [0.10.2] love.math.compress/decompress seems to be leaking memory
How did you detect the leak? Keep in mind, Lua memory is garbage collected, i. e. not immediately freed after use, but only after the next collection cycle. Calling collectgarbage() forces the garbage to be collected immediately, causes unused memory to be freed and usually makes such "leaks" disappear.
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: [0.10.2] love.math.compress/decompress seems to be leaking memory
I called collectgarbage() twice to run a full GC cycle after compressing the data, it doesn't free it up, and the memory usage by love2d keeps on increasing after each compression call. I'm very sure this is a memory leak, because like I said, this does not occur if I just write the serialized data straight to disk without compressing it.
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: [0.10.2] love.math.compress/decompress seems to be leaking memory
Here's the baseline memory usage:
And after hammering ~2k compression calls:
Calling collectgarbage any amount of times has no effect on the memory.
And after hammering ~2k compression calls:
Calling collectgarbage any amount of times has no effect on the memory.
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: [0.10.2] love.math.compress/decompress seems to be leaking memory
Before anything, could you test this with the newest 0.11? Maybe it was a known issue and has been fixed already; note that de/compression went from the love.math to the love.data namespace.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: [0.10.2] love.math.compress/decompress seems to be leaking memory
Can confirm that love.math.compress in 0.10.2 (Debian 9 x64) seems to eat up memory:
Process memory consumption goes up to ~1GB, never goes down. Can't test any other version right now.
Code: Select all
local rand = {}
for i = 1, 2^16 do
rand[i] = string.char(love.math.random(32, 127))
end
local str = table.concat(rand)
for i = 1, 2^14 do
love.math.compress(str)
end
collectgarbage()
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: [0.10.2] love.math.compress/decompress seems to be leaking memory
https://love2d.org/builds/
slime's appveyor, pay attention to choose the latest though, i managed to get the wrong one once. :p
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: [0.10.2] love.math.compress/decompress seems to be leaking memory
There is a memory leak in love.math.compress in 0.10.2, it's already been fixed in the upcoming 0.11.
-
- Party member
- Posts: 106
- Joined: Sat Jun 21, 2014 3:45 pm
Re: [0.10.2] love.math.compress/decompress seems to be leaking memory
Awesome! Thanks for clarifying.
Who is online
Users browsing this forum: No registered users and 2 guests