2009-10-28 02:50:01 Memory Fragmentation problem while running multiple applications
Manu AS (INDIA)
Message: 81799
Hardware: BF561 based board
uClinux release: 2008R1
Issue: We have multiple applications running on BF561 based board. These multiple applications are managed by an Application Manager (AM). The selection of individual application is done through a user interface (UI) provided by AM.
Let us take the following scenario to explain the issue we are facing:
We have 3 applications App1, App2 & App3 managed by AM.
All the 3 applications have different memory requirements.
Now let us assume that user selects App1 through AM UI.
The available memory gets fragmented as per the requirement of App1.
After running App1 for some time, the user switches over to either App2 or App3.
Since the memory requirement of App2 and App3 is entirely different from that of App1, depending on the current memory fragmentation status, and the memory requirement of App2 & App3, the new application may fail.
Even if App2 & App3 runs for the first time, after repeated selection of different applications (in different orders), the memory gets so heavily fragmented that eventually the applications fail to run due to non availability of sufficient contiguous chunk of memory.
Is there any way to tackle this situation? Is there any way to defragment the memory (by calling some API or by any other means) after each application exits?
Note: when a particular application exits, the Application Manager is still alive.
Thanks in advance.
QuoteReplyEditDelete
2009-10-28 11:40:52 Re: Memory Fragmentation problem while running multiple applications
Frank Van Hooft (CANADA)
Message: 81818
Have you tried running a "free" before and after each of these apps, to see if any of them have a memory leak?
QuoteReplyEditDelete
2009-10-28 15:36:51 Re: Memory Fragmentation problem while running multiple applications
Manu AS (INDIA)
Message: 81824
While switching from one application to another application, we are properly shutting down the application. That is all the dynamically allocated memory is freed.
The problem is due to memory fragmentation and not memory leak. The reason is after one application exits, we are seeing that the available free memory is properly increasing. We are also seeing that large contiguous blocks of memory are split into smaller chunks, which confirms that sufficient free memory is available (released by previous application) but it is fragmented.
QuoteReplyEditDelete
2009-10-29 02:35:22 Re: Memory Fragmentation problem while running multiple applications
Yi Li (CHINA)
Message: 81844
Manu,
I thinks the memory fragmentation issue you mentioned is expected on nommu system.
The usual solution is to malloc a block of memory when application starts, then manage it by yourself, and free it when the application exits. This is to avoid frequent malloc/free.
-YI