Today I want to describe a very simple memory allocator – memory pool with fixed block size. Memory allocators are important especially for embedded systems. Such systems often require a memory management module which help to decrease memory fragmentation and provide efficient memory usage.
The idea for a simple memory management module is to allocate memory once and use it frequently. Memory allocation algorithm shouldn’t allocate any memory block outside the pool. It is possible to create more than one memory pool, e.g one memory pool for each queue.
One of the main reason of segmentation fault error is incorrect memory management, e.g freeing unallocated or static space, unauthorized access to unavailable memory. Unfortunately, it isn’t possible to figure out why our application doesn’t work after the segmentation fault message, without any additional tool.
Memory leeks are another problem, which refer to programs written in C/C++. It is especially important in case of embedded systems which are designed to permanently do specific tasks. Embedded C/C++ developers have to provide efficient solution for resource (e.g memory) management.
When we are thinking about the development environment we should think about our comfort. Our efficiency depends on how we feel, so it is important to choose appropriate tools, install and configure them.
During my studies I used many applications which helped me to implement my final projects. Now I’m using Eclipse CDT. In my opinion, it is the best Integrated Development Environment for C/C++ languages. What about console? Vim? Emacs? Well… I’m not a conservative developer ;)
Why Eclipse CDT?
- plugins – external tools inside the development environment
- community – people who help with our problems
- portability – works on many different platforms
- refactoring – fast text and code processing
- many different profilers, simple debugger
Except Eclipse CDT I always use: Valgrind, CUTE, eGIT. I will write about them soon.