High memory usage in vibe.d application

crimaniak crimaniak at gmail.com
Sun Jul 1 20:15:02 UTC 2018


On Sunday, 1 July 2018 at 13:44:23 UTC, Anton Fediushin wrote:

> I reduced the test case to _one_ line:
> ```
> 1.seconds.setTimer(() => "http://google.com".requestHTTP((scope 
> req) {}, (scope res) {res.disconnect;}), true);
> ```
>
> What happens is `res.disconnect` doesn't free all of the 
> internal buffers, causing leakage. One way to avoid that is to 
> call `res.dropBody`, but it isn't always wanted (just like in 
> my example).
  The problem is known and mentioned in the documentation:
http://vibed.org/api/vibe.http.client/requestHTTP

>Note that it is highly recommended to use one of the overloads 
>that take a responder callback, as they can avoid some memory 
>allocations and are safe against accidentally leaving stale 
>response objects (objects whose response body wasn't fully 
>read). For the returning overloads of the function it is 
>recommended to put a scope(exit) right after the call in which 
>HTTPClientResponse.dropBody is called to avoid this.

As I understand the situation, request object will reside in 
memory until you fully read or do something with response body.



More information about the Digitalmars-d-learn mailing list