changeset 23011:ba47ec8a2477

When adding outgoing MSN commands to the MsnHistory, free MsnTransaction->payload to save memory. MSN_HIST_ELEMS * MSN_BUF_LEN (used in msn_message_gen_payload) = 48 * 8192 bytes = 384 KB per online MSN account = a lot of wasted memory
author Mark Doliner <mark@kingant.net>
date Tue, 20 May 2008 20:59:21 +0000
parents 2b91ea8c94d5
children b0c9276bff93
files libpurple/protocols/msn/cmdproc.c libpurple/protocols/msn/msg.c libpurple/protocols/msnp9/cmdproc.c libpurple/protocols/msnp9/msg.c
diffstat 4 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/cmdproc.c	Tue May 20 19:49:26 2008 +0000
+++ b/libpurple/protocols/msn/cmdproc.c	Tue May 20 20:59:21 2008 +0000
@@ -132,6 +132,14 @@
 		data = g_realloc(data, len + trans->payload_len);
 		memcpy(data + len, trans->payload, trans->payload_len);
 		len += trans->payload_len;
+
+		/*
+		 * We're done with trans->payload.  Free it so that the memory
+		 * doesn't sit around in cmdproc->history.
+		 */
+		g_free(trans->payload);
+		trans->payload = NULL;
+		trans->payload_len = 0;
 	}
 
 	msn_servconn_write(servconn, data, len);
--- a/libpurple/protocols/msn/msg.c	Tue May 20 19:49:26 2008 +0000
+++ b/libpurple/protocols/msn/msg.c	Tue May 20 20:59:21 2008 +0000
@@ -151,6 +151,7 @@
 	MsnMessage *msg;
 
 	msg = msn_message_new(MSN_MSG_NUDGE);
+	/* TODO: This shouldn't have a \r\n in it, should it?? */
 	msn_message_set_content_type(msg, "text/x-msnmsgr-datacast\r\n");
 	msn_message_set_flag(msg, 'N');
 	msn_message_set_attr(msg,"ID","1\r\n");
--- a/libpurple/protocols/msnp9/cmdproc.c	Tue May 20 19:49:26 2008 +0000
+++ b/libpurple/protocols/msnp9/cmdproc.c	Tue May 20 20:59:21 2008 +0000
@@ -132,6 +132,14 @@
 		data = g_realloc(data, len + trans->payload_len);
 		memcpy(data + len, trans->payload, trans->payload_len);
 		len += trans->payload_len;
+
+		/*
+		 * We're done with trans->payload.  Free it so that the memory
+		 * doesn't sit around in cmdproc->history.
+		 */
+		g_free(trans->payload);
+		trans->payload = NULL;
+		trans->payload_len = 0;
 	}
 
 	msn_servconn_write(servconn, data, len);
--- a/libpurple/protocols/msnp9/msg.c	Tue May 20 19:49:26 2008 +0000
+++ b/libpurple/protocols/msnp9/msg.c	Tue May 20 20:59:21 2008 +0000
@@ -158,6 +158,7 @@
 	MsnMessage *msg;
 
 	msg = msn_message_new(MSN_MSG_NUDGE);
+	/* TODO: This shouldn't have a \r\n in it, should it?? */
 	msn_message_set_content_type(msg, "text/x-msnmsgr-datacast\r\n");
 	msn_message_set_flag(msg, 'N');
 	msn_message_set_attr(msg,"ID","1\r\n");