## [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
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

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: 642
Joined: Sat Jul 22, 2017 7:43 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.

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

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

Here's the baseline memory usage:

And after hammering ~2k compression calls:

Calling collectgarbage any amount of times has no effect on the memory.

zorg
Party member
Posts: 2995
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.

grump
Party member
Posts: 642
Joined: Sat Jul 22, 2017 7:43 pm

### 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:

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

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?

zorg
Party member
Posts: 2995
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

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 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: 2902
Joined: Mon Aug 23, 2010 6:45 am
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.

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

Awesome! Thanks for clarifying.

### Who is online

Users browsing this forum: No registered users and 33 guests