" Lock the Malloc"
PC: Google

" Lock the Malloc"

Malloc is a popular function because it offers several advantages like optimized usage of RAM ( unlike array which is highly non optimal) and ease of building generic framework to implement things like decision trees ( where input length is variable) , DNNs and CNNs with varying number of input and output nodes , varying number of hidden layers etc.

Unfortunately, one of the most dangerous constructs to use in any embedded program is malloc, because it could potentially lead to memory leaks, dangling pointers, memory corruption, program

The key question to answer is "can we still use malloc and remain safe"

One of the ways to safely use #malloc without compromising benefits offered is : "Partitioned memory based upper bounded, dynamic maximum size allocation to elements requiring malloc"

1. First and foremost, all the elements using malloc must be able to allocate memory from a separate partition typically called as heap.

2. Next is fixed maximum memory size allocation limit statically decided and allocated to each element requiring dynamic memory access

3. Last but not the least, the available limit statically decided can be updated dynamically after invocation of every call to #free

If these rules are not followed the program is sitting on a time bomb which could explode any time, anywhere !

要查看或添加评论,请登录

Koustubh Tilak的更多文章

社区洞察

其他会员也浏览了