Arch.Extended icon indicating copy to clipboard operation
Arch.Extended copied to clipboard

World grows after deserialization

Open richdog opened this issue 1 year ago • 2 comments

Every time I save the same world after loading, the world grows. This happens even if I save an empty world. This also happens with both Binary and JSON serialization.

I've attached two copies of the world JSON, once from the first save, and again after loading and saving again. note that it keeps growing every time I save and load, not just the first time.

world-empty-1.json world-empty-2.json

I tracked it to this point: image image

I dug a bit deeper after this and it seems to do with the way the capacity is calculated, and serialized. I attempted serializing/deserializing the capacity of just a single bucket instead of the total capacity, which seemed to partially fix the issue, but it would still grow in some cases so I moved on to other things.

richdog avatar Dec 18 '23 02:12 richdog

image

image

I found it. Firstly we set capacity in JaggedArray constructor. Then we EnsureCapacity and check newCapacity < Capacity (They are same by constructor) so it increases capacity again.. I think fix should be simple @genaray @richdog

Upd. I tried to remove world.EnsureCapacity(versions.Capacity); in serializer. It helped a bit, but still leaking.

ArhinZi avatar Mar 31 '24 21:03 ArhinZi

Thanks! What do you think is the second leak problem?

genaray avatar Apr 08 '24 20:04 genaray