牛骨文教育服务平台(让学习变的简单)
博文笔记

MySQL C API造成内存泄漏

创建时间:2016-10-11 投稿人: 浏览次数:1212


使用C操作MySQL,程序完成时使用Valgrind检测,发现有内存泄漏。

==4785== LEAK SUMMARY:
==4785==    definitely lost: 0 bytes in 0 blocks
==4785==    indirectly lost: 0 bytes in 0 blocks
==4785==      possibly lost: 0 bytes in 0 blocks
==4785==    still reachable: 65,432 bytes in 17 blocks
==4785==         suppressed: 0 bytes in 0 blocks

使用mysql_library_end()函数来释放剩余的内存。

This function finalizes the MySQL library. Call it when you are done using the library (for example, after disconnecting from the server). The action taken by the call depends on whether your application is linked to the MySQL client library or the MySQL embedded server library. For a client program linked against the libmysqlclient library by using the -lmysqlclient flag, mysql_library_end() performs some memory management to clean up. For an embedded server application linked against the libmysqld library by using the -lmysqld flag, mysql_library_end() shuts down the embedded server and then cleans up.

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。