Open alexeibs opened 9 years ago
It looks like the GC isn't collecting, what windows version are you using? Maybe you can try a basic allocation test? e.g. running new char[500];
in a loop
Also, try using the scope
keyword in your parameters, e.g. scope HTTPServerRequest ...
I couldn't compile with x86 so I compiled your test with libasync and saw no leaks, can you confirm?
OS - Window 7 x64 I replaced this
response.contentType = "image/jpeg";
response.bodyWriter.write(globalBuffer);
by this
response.writeBody(globalBuffer, "image/jpeg");
After that memory usage grows much slower.
Which version of DMD are you using?
DMD 2.068
Does the following change help?
void getIndex(scope HTTPServerRequest request, scope HTTPServerResponse response) {
response.render!("index.dt", request);
}
void getImage(scope HTTPServerRequest request, scope HTTPServerResponse response) {
response.contentType = "image/jpeg";
response.bodyWriter.write(globalBuffer);
}
No, it doesn't. But if I replace getImage code with 'response.writeBody(globalBuffer, "image/jpeg");' it helps a lot. Memory usage still grows but very slowly.
Here is a test program:
index.dt
script.js
I run it with 1920x1080 jpeg file (~500k). The server crashes quite fast after consuming about 1,5 Gb RAM with this error: