Reputation: 25
I'm working on embedded device (STM32) with < 5kb
free FLASH memory left. I'm trying to compress string
with zlib library.
I created function HERE and it returns -2
(Z_STREAM_ERROR
).
What I did:
zconf.h
, I changed value of MAX_MEM_LEVEL
to 1
and MAX_WBITS
to 5
to lower memory usage. But i still returns -2
(Z_STREAM_ERROR
).Then I found this On deflate.c
which I cannot lower MAX_WBITS
less than 8
:
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
return Z_STREAM_ERROR;
}
if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
Then I set it to MAX_MEM_LEVEL
to 1
and MAX_WBITS
to 8
but when I try to compile it always returns region FLASH overflowed by 15960 bytes
. Looks like I run out of memory.
Then I tried another example:
CHUNK
to 1024
.Result still the same, region FLASH overflowed by 15960 bytes
.
Is there any other way to do it with FLASH memory only 5kb
left?
Note:
5kb
left.Upvotes: 0
Views: 984
Reputation: 112422
No. The minimum amount of RAM required by deflate is 9K. You might try a different compressor, such as lz4.
The deflate code itself compiles to 33K on my machine (x86_64 ISA), with speed optimization. I tried compiling with aggressive space optimization, which got it down to 25K.
Upvotes: 1