Memory leak control with hash table

本文介绍了OpenSSL中如何实现内存分配及泄漏检测机制。主要内容包括:重新实现内存分配函数、使用哈希表记录每次分配、设置标记控制内存监控、利用锁隔离内外分配过程以及提供回调函数清理泄露内存。

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

It’s not an easy job, careful design and consideration is needed to make memory allocation and free robust and efficiency. Here just go through the way Open SSL conducting memory leak. Here just give the brief instruction and architecture.

 

1, re-implement the memory allocate function,

2, use a hash table to record every allocation, restored in node mem_st.

3, use a trigger flag to control if monitors all the memory allocation. Such as CRYPTO_MEM_CHECK_ON and CRYPTO_MEM_CHECK_OFF.

4, have to use a memory lock to separate the inner and outer allocation. MemCheck_off() and MemCheck_on(), still it’s not very clear to meL.

5, the callback function CRYPTO_mem_leaks_cb() can be used to cleanup all the leak memory.

 

Why the OPEN SSL only have the function to printout all the leak memory, and don’t have the standard function to free them? Maybe it has to be implement by the users themselves.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值