[lkml]   [2003]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectDynamic memory stack?
A good way to prevent memory leaks and simplify code is to reduce the use of
kmalloc for a certain class of situations. Specifically, I am referring to
blocks of code with the following:


This sort of thing is best handled on the stack, but, of course, that has
critical flaws. A way to deal with this is to create a per-cpu kmalloc'ed
dynamically extended stack from which memory can be allocated. Then, most
allocations/deallocations are done in O(1) and memory fragmentation due to
lots of small allocation is avoided.
Furthermore, with the help of macros, memory leaks due to mid-function returns
and such can be completely avoided.
A survey of kernel code revealed a number of places where this methodology can
be applied.
-Alex Khripin
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:32    [W:0.036 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site