Memory growth when using SOUP_ENCODING_CHUNKED
- From: "W. Michael Petullo" <mike flyn org>
- To: libsoup-list gnome org
- Subject: Memory growth when using SOUP_ENCODING_CHUNKED
- Date: Sun, 25 Jan 2009 22:37:08 -0500 (EST)
I am working on libdmapsharing, a GObject-based DMAP (DAAP / DPAP) library
that uses libsoup 2.4. The libdmapsharing project is available at
http://sourceforge.net/projects/libdmapsharing/.
Everything works fine when I share files using mmap'ed IO. However, for
large files, I would like to use SOUP_ENCODING_CHUNKED.
Right now, my code increases its memory usage drastically as a file is
being sent to a client.
My understanding is that soup_message_body_append () appends to a buffer
that will be sent to the client as soon as possible after
soup_server_unpause_message () is called. Hence, the buffer will not grow
too big as it is continously being sent and then free'ed (i.e., the buffer
does wait to aquire the entire contents of a large file before being sent
and free'ed).
Is this how it is supposed to work?
My wrote_chunk callback function is as follows, am I doing anything wrong
in it?
static void
write_next_chunk (SoupMessage *message, ChunkData *cd)
{
gssize read_size;
GError *error = NULL;
gchar *chunk = g_malloc (DMAP_SHARE_CHUNK_SIZE);
read_size = g_input_stream_read (cd->stream,
chunk,
DMAP_SHARE_CHUNK_SIZE,
NULL,
&error);
if (read_size > 0) {
soup_message_body_append (message->response_body,
SOUP_MEMORY_TAKE,
chunk,
read_size);
g_warning ("wrote %d bytes", read_size);
} else {
if (error != NULL) {
g_warning ("error reading from input stream: %s",
error->message);
g_error_free (error);
}
g_free (chunk);
soup_message_body_complete (message->response_body);
}
soup_server_unpause_message (cd->server, message);
}
Thank you.
Mike
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]