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

本文详细介绍了TinyXML在Symbian平台移植过程中遇到的内存泄漏问题,并深入分析了TiXmlDocument::LoadFile()函数中导致内存泄漏的具体原因。通过加入CloseSTDLIB()函数调用来释放线程本地存储资源,成功解决了内存泄漏问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近在把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

 

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值