Skip to content

huge memory use when upload large file with form-data #352

@gary8520

Description

@gary8520

Hi,
We meet an issue that turbo will occupy memory up to three times of upload file size during the request.
If we need to upload file with size 60MB, it will use memory up to 180MB. It would cause out of memory in the embedded system with limited memory.

After tracing code, the memory use as below:
one is buffer enlarged in the iostream.IOStream:_read_to_buffer() calling self._read_buffer:append_right()
one is convert ffi.string to lua string in iostream.IOStream:_consume() as request.body
one is string slice argument[1] = data:sub(v1, b2) during parsing multipart httputil.parse_multipart_data()

In our scenario we need to save the file in the handler, it would cost one more time of memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions