c - Axis2C内存泄漏?

标签 c valgrind axis2c

我正在使用 Axis2C。我正在使用一个简单的 Web 服务客户端进行一些测试来测试这个框架。

我使用 Apache 提供的一些示例和文档编写了客户端。客户端工作正常,我决定使用 valgrind 对其进行测试,以确保内存管理正确。

我使用示例和文档中提到的函数来释放内存(在本例中):

// to free the requst struct.
 adb_EncryptRequest_free(request, env);

 // to free the stub.
 axis2_stub_free(stub, env);

 // to free the environment.
 axutil_env_free((axutil_env_t*) env);

我的代码中没有任何“狂野”的 new 或 malloc。

但是,valgrind 报告以下内容:

LEAK SUMMARY:
==2287==    definitely lost: 56 bytes in 3 blocks
==2287==    indirectly lost: 156 bytes in 5 blocks
==2287==      possibly lost: 0 bytes in 0 blocks
==2287==    still reachable: 20 bytes in 1 blocks
==2287==         suppressed: 0 bytes in 0 blocks

我使用 --leak-check=full 重新运行 Valgind,但据我了解,内存问题位于 axis2c *.so 文件中。

HEAP SUMMARY:
==2292==     in use at exit: 232 bytes in 9 blocks
==2292==   total heap usage: 13,180 allocs, 13,171 frees, 760,422 bytes allocated
==2292== 
==2292== 68 (16 direct, 52 indirect) bytes in 1 blocks are definitely lost in loss record 7 of 9
==2292==    at 0x400677E: malloc (vg_replace_malloc.c:195)
==2292==    by 0x40C2032: axutil_allocator_malloc_impl (in /home/EMBT/Downloads/axis2c-bin-1.6.0-linux/lib/libaxutil.so.0.6.0)
==2292==    by 0x40C5C07: axutil_string_create (in /home/EMBT/Downloads/axis2c-bin-1.6.0-linux/lib/libaxutil.so.0.6.0)
==2292==    by 0x804E024: axis2_stub_start_op_PoCPCIServiceService_GetEncryptedData (axis2_stub_PoCPCIServiceService.c:493)
==2292==    by 0x804E759: main (main.c:59)
==2292== 
==2292== 72 (20 direct, 52 indirect) bytes in 1 blocks are definitely lost in loss record 8 of 9
==2292==    at 0x400677E: malloc (vg_replace_malloc.c:195)
==2292==    by 0x40C2032: axutil_allocator_malloc_impl (in /home/EMBT/Downloads/axis2c-bin-1.6.0-linux/lib/libaxutil.so.0.6.0)
==2292==    by 0x40C74F5: axutil_qname_create (in /home/EMBT/Downloads/axis2c-bin-1.6.0-linux/lib/libaxutil.so.0.6.0)
==2292==    by 0x804D515: axis2_stub_populate_services_for_PoCPCIServiceService (axis2_stub_PoCPCIServiceService.c:91)
==2292==    by 0x804D395: axis2_stub_create_PoCPCIServiceService (axis2_stub_PoCPCIServiceService.c:48)
==2292==    by 0x804E6ED: main (main.c:46)
==2292== 
==2292== 72 (20 direct, 52 indirect) bytes in 1 blocks are definitely lost in loss record 9 of 9
==2292==    at 0x400677E: malloc (vg_replace_malloc.c:195)
==2292==    by 0x40C2032: axutil_allocator_malloc_impl (in /home/EMBT/Downloads/axis2c-bin-1.6.0-linux/lib/libaxutil.so.0.6.0)
==2292==    by 0x40C74F5: axutil_qname_create (in /home/EMBT/Downloads/axis2c-bin-1.6.0-linux/lib/libaxutil.so.0.6.0)
==2292==    by 0x804D64F: axis2_stub_populate_services_for_PoCPCIServiceService (axis2_stub_PoCPCIServiceService.c:111)
==2292==    by 0x804D395: axis2_stub_create_PoCPCIServiceService (axis2_stub_PoCPCIServiceService.c:48)
==2292==    by 0x804E6ED: main (main.c:46)

如果我是对的,有办法解决吗?

感谢您的帮助。

问候。

最佳答案

没有代码,它只是猜测。我使用了axis2c(来自svn的1.7.x)并且没有注意到任何泄漏(在vc中用visual leak detector检查)。

我只释放了服务客户端和环境。

 axis2_svc_client_free(svc, env);
 axutil_env_free(env);

根据header注释您与“axis2_svc_client_send_receive”(在生成代码中使用)绑定(bind)的数据由服务客户端释放。

关于c - Axis2C内存泄漏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10108438/

相关文章:

visual-studio-2008 - 带有 OpenSSL 的 Axis2C - 没有 OPENSSL_APPLINK 错误

c - 从 UITextField 获取文本然后将其放入外部类的最佳方法是什么?

c - 帮助 ICMP 欺骗

c - 如何释放从另一个函数返回的 char*?

c - 分配还是不分配。大小 1 错误的读取无效。 【凝视2小时】

c - 如何使用 wsdl2c 工具构建启用 SSL 的客户端代码以与 axis2 一起使用?

c - 带 OpenGL 的嵌套剪刀盒

c - 代码中可能存在内存错误以及可能的解决方案?

c - 内存泄漏双指针

c - 如何使用Axis2c从WSDL文件生成C文件