Skip to content

Consuming a large amount of memory when unpacking huge Array and Map unexpectedly #657

@napo0703

Description

@napo0703

There is a problem of unexpectedly consuming a large amount of memory when unpacking huge Array and Map.
For example, this code may causes an OutOfMemoryError.

    public static void unpackHugeArray()
            throws IOException
    {
        MessageBufferPacker packer = MessagePack.newDefaultBufferPacker();
        packer.packArrayHeader(2147483647);
        packer.close();

        byte[] packedData = packer.toByteArray();
        MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(packedData);
        unpacker.unpackValue();  // Caused by: java.lang.OutOfMemoryError
        unpacker.close();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions