Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializing/Deserialzing Large Arrays - Length header size is larger than buffer size #338

Open
dexsper opened this issue Oct 9, 2024 · 5 comments

Comments

@dexsper
Copy link

dexsper commented Oct 9, 2024

I use MemoryPack to save building information in the game world. And everything works fine usually, hundreds of people downloading and saving their builds at the same time. But when I wanted to migrate and add a new field manually (deserialize old format -> serialize to new format) I started getting a header size error:

Unhandled exception. MemoryPack.MemoryPackSerializationException: Length header size is larger than buffer size, length: 218103807.

Serializing:

List<EntityData> entitiesData = ...
using var compressor = new BrotliCompressor();
MemoryPackSerializer.Serialize(compressor, entitiesData); 

Deserializing:

byte[]? data = ...
using var decompressor = new BrotliDecompressor();
MemoryPackSerializer.Deserialize(decompressor.Decompress(data), ref entitiesData!);

I don't have the ability to use streaming serialization like.
And during migration I need to deserialize about 10000 files (~150 kilobytes each) and serialize again

@dexsper
Copy link
Author

dexsper commented Oct 9, 2024

It happens at the point when it comes to deserializing textures in some files

image

@neuecc
Copy link
Member

neuecc commented Oct 10, 2024

Thank you.
It looks like there's a problem with the compression.
I'll check it out.

@dexsper
Copy link
Author

dexsper commented Oct 14, 2024

I don't know if this will help you to fix the error, but I managed to avoid it by checking that the array is empty, having previously marked Payload and Textures as nullable - apparently at some point an array with size 0 was created.

@79loli
Copy link

79loli commented Nov 14, 2024

Length header size is larger than buffer size, length: 8704.

@79loli
Copy link

79loli commented Nov 14, 2024

Specified argument was out of the range of valid values.
Parameter name: capacity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants