Symbian 使用 fopen() 内存泄漏的解决方法

来源:互联网 发布:js用户名密码验证 编辑:程序博客网 时间:2024/06/06 08:59

最近在把TinyXML移植到Symbian平台,可是一直存在内存泄漏,经过检查,内存泄漏原因在TiXmlDocument::LoadFile()中, 

 

如上代码所示,加上CloseSTDLIB()后,内存泄漏消失,不调用CloseSTDLIB会出现内存泄露。

 

必须调用CloseSTDLIB的原因是:
Because the data allocated in the thread-local storage for STDLIB's DLL (the _reent structure) is not automatically cleaned up when the environment is destroyed, it must be cleaned up by the user of STDLIB.

The function to achieve this is CloseSTDLIB(). To use this function, file epoc32/include/libc/sys/reent.h should be included in the project. Call CloseSTDLIB() after the point at which it is known that code in STDLIB's DLL will no longer be called and its thread-local storage no longer needed.

 

 

 

参考:http://discussion.forum.nokia.com/forum/showthread.php?t=165359

 

 


原创粉丝点击