fix: add BLOCK_OVERHEAD before round size#2652
Conversation
|
I might be missing something, but with |
1 << -1 |
|
Good catch! |
|
Still not seeing how this becomes |
|
Hmm, it should be possible when |
|
Yes, you are right. I have edited the message. |
|
However, I can't reproduce this problem in playground What am I doing wrong? |
|
Thanks for the clarification. So, from locking at the code, assemblyscript/std/assembly/rt/tlsf.ts Lines 489 to 494 in b745216 There, the size passed to |
|
I think for reproduction of this we should have |
|
Doesn't seem to me that the issue depends on the current size of memory. At least the computation in question doesn't use it (neither |
|
It is easy to re-produce it. These code will trace memory.size is 32770 at last instead of 2. for (let i=0;i<6000;i++) {
heap.alloc(1);
trace("", 1, memory.size());
}I found some unusual memory consumption behavior from the monitor and find the root cause. |
BLOCK_MINSIZE is 12 instead of 16 @dcodeIO |
|
Is the underlying problem perhaps that assemblyscript/std/assembly/rt/tlsf.ts Lines 311 to 329 in 688746a If so, perhaps instead of reordering the logic, mirroring exactly what |
6503c53 to
4ac70f7
Compare
When calling
heap.alloc(1), It will alloc a block size =BLOCK_MINSIZE(12bytes)And then
invRound = 27
clz(size) = 28
(1 << (invRound - clz(size))) - 1 = 2147483647
Runtime will grow lots of memory.