OK guys,
Well, this is self replying though, I kinda found where the
prob resides. I found some comments related to leak that says:
(xmlrpc_client.c around line 500)
/* WARNING: We can't delete the destination anchor, because this points
** to something in the outside world, and lives in a libwww hash table.
** Under certain circumstances, this anchor may have been reissued to
** somebody else. So over time, the anchor cache will grow. If this
** is a problem for your application, read the documentation for
** HTAnchor_deleteAll.
**
** However, we CAN check to make sure that no documents have been
** attached to the anchor. This assertion may fail if you're using
** libwww for something else, so please feel free to comment it out. */
It seems calling HTAnchor_deleteAll() thing here could be problemtic
but I gave it try calling HTAnchor_deleteAll() at the end of call_info_free()
right before free(info):
XMLRPC_ASSERT(HTAnchor_document(info->dest_anchor) == NULL);
/* Now I go to be little brave to call HTAnchor_deleteAll here.
** I updated libwww to 5.4.0 and seems working now.*/
HTAnchor_deleteAll(xmlrpc_conversions);
free(info);
After this fix the leak I had is gone. Although if I did right this here
or not it's working with no leak with 10,000 RPC with base64 decoding.
Let me know if any problems or suggestions.
-- Kane
On Thursday 27 May 2004 10:36, Linux wrote:
> Hi guys
>
> I've been working on some small utility that uses XML-RPC to
> request jobs on server. I'm using Eric Kid's XML-RPC/C/C++
> library. Lastnight I ran test app all night and found there's
> memory leak with my app. I looked in to my code but it is
> too simple, there's no way to cause the leak in my code.
> So I used sample code to repro the leak and found it does.
> The server seems OK but client. While client is running,
> it eats up memory, very small amount like 30K/sec., but
> it definitely grows slowly...
>
> Here's the code:
> (I'm using w3c-libwww-5.4.0 and xmlrpc-c-0.9.10)
>
> //
> // Client source
> //
> #include <stdio.h>
>
> #include "xmlrpc.h"
> #include "xmlrpc_client.h"
>
> #define NAME "XML-RPC C Test Client"
> #define VERSION "0.1"
>
> static void die_if_fault_occurred (xmlrpc_env *env)
> {
> if (env->fault_occurred) {
> fprintf(stderr, "XML-RPC Fault: %s (%d)\n",
> env->fault_string, env->fault_code);
> exit(1);
> }
> }
>
>
> int main (int argc, char** argv)
> {
> xmlrpc_env env;
> xmlrpc_value *result;
> xmlrpc_int32 sum;
>
> //
> //do{ loop #1 <== When I put do/while here it went worse...
> //
> /* Start up our XML-RPC client library. */
> xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, NAME, VERSION);
> xmlrpc_env_init(&env);
>
> do{ // loop #2
> /* Make a whole bunch of asynchronous calls. */
> result = xmlrpc_client_call(&env, "http://localhost/RPC2",
> "sample.add",
> "(ii)",
> (xmlrpc_int32) 3, (xmlrpc_int32) 2);
> die_if_fault_occurred(&env);
>
> /* Parse our result value. */
> xmlrpc_parse_value(&env, result, "i", &sum);
> die_if_fault_occurred(&env);
>
> /* Print out our sum and difference. */
> printf("===> Sum: %d\n", (int) sum);
>
> //
> //} while(1); wend of loop #2 <== Putting while(1) here seems no
> difference. //
> /* Dispose of our result value. */
> xmlrpc_DECREF(result);
>
> } while(1); // loop #2
>
> /* Shutdown our XML-RPC client library. */
> xmlrpc_env_clean(&env);
> xmlrpc_client_cleanup();
> //
> //} while(1); loop #1 <== This loop even worse.
> //
> return 0;
> }
>
> //
> // Server source
> //
> /* A simple standalone XML-RPC server written in C. */
>
> #include <stdio.h>
> #include <stdlib.h>
>
> #include <xmlrpc.h>
> #include <xmlrpc_abyss.h>
>
> xmlrpc_value *
> sample_add (xmlrpc_env *env, xmlrpc_value *param_array, void *user_data)
> {
> xmlrpc_int32 x, y, z;
>
> /* Parse our argument array. */
> xmlrpc_parse_value(env, param_array, "(ii)", &x, &y);
> if (env->fault_occurred)
> return NULL;
>
> /* Add our two numbers. */
> z = x + y;
>
> /* Return our result. */
> return xmlrpc_build_value(env, "i", z);
> }
>
> int main (int argc, char **argv)
> {
> if (argc != 2) {
> fprintf(stderr, "Usage: servertest abyss.conf\n");
> exit(1);
> }
>
> xmlrpc_server_abyss_init(XMLRPC_SERVER_ABYSS_NO_FLAGS, argv[1]);
> xmlrpc_server_abyss_add_method("sample.add", &sample_add, NULL);
>
> printf("server: switching to background.\n");
> xmlrpc_server_abyss_run();
>
> return 0;
> }
>
> Any clue? If it won't work then I'll probably need to switch to Java.
>
> Thank you,
>
> -- Kane
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/xml-rpc/
<*> To unsubscribe from this group, send an email to:
xml-rpc-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|