Thank you! I added: msg.response_body.set_accumulate (false);
Now it works correctly and the memory is stable. The performace is good also with MemoryUse.COPY. I do not understand the difference between EOF and CHUNKED about the connection. I will study better. Thank you. 2013/9/25 Evan Nemerson <e...@coeus-group.com> > On Tue, 2013-09-24 at 14:24 +0200, andrea zambon wrote: > > I am developing a service http with libsoup, but I have a memory problem. > > When you make a request, the service memory increases during transmission > > and decreases only after the closure of the service. Another call and > will > > increase again. > > See the API docs for Soup.MessageBody.set_accumulate: > http://valadoc.org/libsoup-2.4/Soup.MessageBody.set_accumulate.html > > I have no idea if it will work for encodings other than chunked, but I > don't see a reason why you would want to close the connection after > every request, so why not just use chunked? > > > The client is in another machine and the data may be very long (2 GB). > > I try to user Soup.MemoryUse.TAKE but I get garbage data. > > The Soup.Buffer is not free when sending a new buffer? > > Using the default Soup.Buffer constructor with Soup.MemoryUse.TAKE is > very difficult to get right. That flag is telling libsoup: > > "The caller has allocated the memory for the SoupBuffer's use; > libsoup will assume ownership of it and free it (with g_free()) > when it is done with it." > > However, Vala isn't actually aware of the interaction between this > parameter and libsoup's memory management. According to the bindings, > the argument does not transfer ownership, which means Vala will free the > buffer for you, then it is likely to get reallocated somewhere else and > have its contents changed. Furthermore, when libsoup tries to free it > your program will likely crash. > > If you want to transfer ownership, you should use the Soup.Buffer.take > constructor. By default valac will actually make a copy of the buffer > for you, so if you want to pass along your reference (which will > invalidate your local copy), use the (owned) keyword: > > var buffer = new Soup.Buffer.take ((owned) data); > > I'm attaching a version of a server I wrote a while back which you may > want to take a look at. It uses chunked encoding for larger files, > while smaller files are mmaped and use content length encoding. It's > also pretty good about doing things asynchronously when possible. > > > -Evan > _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list