[0.10.2] love.math.compress/decompress seems to be leaking memory

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

[0.10.2] love.math.compress/decompress seems to be leaking memory

Post by Whatthefuck »

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.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: [0.10.2] love.math.compress/decompress seems to be leaking memory

Post by grump »

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.
Whatthefuck
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

Post by Whatthefuck »

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.
Whatthefuck
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

Post by Whatthefuck »

Here's the baseline memory usage:
Image
And after hammering ~2k compression calls:
Image

Calling collectgarbage any amount of times has no effect on the memory.
User avatar
zorg
Party member
Posts: 3436
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

Post by zorg »

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 :3True 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.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: [0.10.2] love.math.compress/decompress seems to be leaking memory

Post by grump »

Can confirm that love.math.compress in 0.10.2 (Debian 9 x64) seems to eat up memory:

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()
Process memory consumption goes up to ~1GB, never goes down. Can't test any other version right now.
Whatthefuck
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

Post by Whatthefuck »

zorg wrote: Thu Mar 01, 2018 2:21 pm 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.
Any windows builds of it anywhere for a quick test?
User avatar
zorg
Party member
Posts: 3436
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

Post by zorg »

Whatthefuck wrote: Thu Mar 01, 2018 2:31 pm
zorg wrote: Thu Mar 01, 2018 2:21 pm 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.
Any windows builds of it anywhere for a quick test?
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 :3True 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.
User avatar
slime
Solid Snayke
Posts: 3131
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

Post by slime »

There is a memory leak in love.math.compress in 0.10.2, it's already been fixed in the upcoming 0.11.
Whatthefuck
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

Post by Whatthefuck »

Awesome! Thanks for clarifying.
Post Reply

Who is online

Users browsing this forum: No registered users and 57 guests