# HTTP.parse\_multipart\_form does a lot of memory allocations

**URL:** <https://discourse.julialang.org/t/http-parse-multipart-form-does-a-lot-of-memory-allocations/66661>\
**Category:** Web Stack\
**Created:** [August 19, 2021, 10:08am UTC](https://discourse.julialang.org/t/http-parse-multipart-form-does-a-lot-of-memory-allocations/66661 "2021-08-19T10:08:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan\_Dolinsky](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jan_dolinsky/32/31347_2.png) [@Jan\_Dolinsky](https://discourse.julialang.org/u/Jan_Dolinsky)\
**Post date:** [August 19, 2021, 10:08am UTC](https://discourse.julialang.org/t/http-parse-multipart-form-does-a-lot-of-memory-allocations/66661/1 "2021-08-19T10:08:38Z")

</div>

Hello,

I tried a simple example of parsing a multi-part HTTP request (JSON config + some CSV data). The request is about 5MB big. Doing just

```julia
const r = deserialize("httpRequestStored") # just to get the request that was serialized for convenience earlier 

function testParsing(request)
    HTTP.parse_multipart_form(request)
end

@benchmark testParsing($r)
BenchmarkTools.Trial: 
  memory estimate: 584.20 MiB
  allocs estimate: 4785904
  --------------
  minimum time: 190.401 ms (6.29% GC)
  median time: 194.841 ms (6.66% GC)
  mean time: 196.294 ms (6.67% GC)
  maximum time: 213.147 ms (5.62% GC)
  --------------
  samples: 26
  evals/sample: 1

```

results in about 500MB of allocations. This is quite a lot for just parsing 5MB worth of data. Any idea what is wrong / how to fix this? I assume that I am doing benchmarking right.

I am on Julia v1.5.4 and HTTP v0.9.7.

Thanks,  
Jan

---

<div class="post-metadata">

**Author:** ![Jan\_Dolinsky](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jan_dolinsky/32/31347_2.png) [@Jan\_Dolinsky](https://discourse.julialang.org/u/Jan_Dolinsky)\
**Post date:** [September 2, 2021, 9:55am UTC](https://discourse.julialang.org/t/http-parse-multipart-form-does-a-lot-of-memory-allocations/66661/2 "2021-09-02T09:55:27Z")

</div>

This pull request [https://github.com/JuliaWeb/HTTP.jl/pull/745](https://github.com/JuliaWeb/HTTP.jl/pull/745) solves the overhead I was reporting. Great job! Thanks! @quinnj @mbauman
