tamasfe/aide

RAM usage

Closed this issue · 5 comments

javihc commented

After using aide for generating the OpenApi doc for an API the memory consumption has increased from a couple of megabytes to more than a gigabyte. Is it my problem or aide use a lot of RAM?

I'm not seeing this in my servers. Do memory profilers indicate that aide objects are using/leaking that RAM?

Maybe #48 is related?

Wicpar commented

yeah it's odd and error prone to leak memory like this. It could be solved using Bytes from the bytes crate, Html<Bytes>. However it's unlikely that is the issue as the string is leaked once only and only if you setup redoc

We've been using aide in production for a while now and haven't observed any leaks, although without redoc. The API document should be generated only once, how you serve it afterwards is up to you (the examples in the docs are inefficient for the sake of simplicity).

Feel free to reopen this once it is confirmed that the issue is with aide and/or you have a reproducible example.

Wicpar commented

Hello, so actually i pinpointed the ram usage issue exactly to aide, but not exactly the crate. Turns out it is absolutely imperative to wrap the OpenAPI struct when used in an Extension with an Arc, else it will be cloned for every single connection.