|
In the thread "anyone know how to check free space on RCX?" the issue of
checking for memory leaks was raised.
I wanted to mention that I have some code that may help in that area. I
wrote a function for the memory manager called mm_defrag() It searches the
memory map for any blocks that can be recombined with adjacent blocks (using
code already in the mm.c) See the explaination below:
If you save the value from mm_free_mem(); allocate a block of memory; free
the memory, then call mm_free_mem(); you may get a different value from the
one you saved previously. This is because the freed block header is still
occupying some memory. To get around this, you can call mm_defrag() then
call mm_free_mem() each time you need to know the amount of free memory.
This will give consistent values.
If anyone is interested, I will post the mm_defrag() code. If it is useful,
I suggest it be included in a future release of legOS.
// Joe
p.s. The kernel could delay defragmenting memory until it hits a threshold.
Or even do partial defragmentation just prior to running the idle task.
This could equate to a performance boost for most programs. Anyone
agree/disagree?
|
|
Message has 1 Reply: | | Re: detecting memory leaks
|
| (...) Please, post. (...) I'm guessing you defrag using mm_try_join()? malloc() uses this to defrag the beginning of the pool until it finds a big enough block (which can then be split again if its too big); Defragging during idle would save this (...) (22 years ago, 12-Jul-02, to lugnet.robotics.rcx.legos)
|
5 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|