Discussion:
defragment memory in Windows CE 5.0
(too old to reply)
paul
2008-10-20 09:08:07 UTC
Permalink
Hi,
Is it possible to defragment memory in Windows CE 5.0?

Can somebody give me some points how to do it with Visual Studio 2005?

Thanks,
Luca Calligaris
2008-10-20 09:25:35 UTC
Permalink
If your OS includes FATUTIL.DLL you cal call the API DefragVolumeEx
--
Luca Calligaris
www.eurotech.it
Post by paul
Hi,
Is it possible to defragment memory in Windows CE 5.0?
Can somebody give me some points how to do it with Visual Studio 2005?
Thanks,
paul
2008-10-20 09:42:52 UTC
Permalink
Thank you, Luca.
But I checked the MSDN about the API, it is for defragmenting disk.
We want to defragment memory to avoid out of memory error when ask
memory from heap.
I googled there is a runtime memory defragmenter in WM2003 by adding a
key in registry: HKCU\Software\Microsoft\Shell\NeverDorkMemory
It does not work in Windows CE 5.0!

Do you have any ideas?
Thanks,

On 10$B7n(B20$BF|(B, $B2<8a(B5$B;~(B25$BJ,(B, "Luca Calligaris"
Post by Luca Calligaris
If your OS includes FATUTIL.DLL you cal call the API DefragVolumeEx
--
Luca Calligariswww.eurotech.it
Post by paul
Hi,
Is it possible to defragment memory in Windows CE 5.0?
Can somebody give me some points how to do it with Visual Studio 2005?
Thanks,
Paul G. Tobey [eMVP]
2008-10-20 16:04:19 UTC
Permalink
That's generally not possible. Remember that the programs using that memory
have pointers, fixed addresses that indicate to the programs where important
pieces of data are located. The key there is "fixed". If you move memory
around, all of a sudden the code will stop work, spectacularly. The managed
heap knows about all (or at least most), instances of memory allocations and
can take steps to move things in the heap around, if they are not fixed, but
you can't generally do that to the total memory space of a system without
crashing everything.

Paul T.
Post by paul
Thank you, Luca.
But I checked the MSDN about the API, it is for defragmenting disk.
We want to defragment memory to avoid out of memory error when ask
memory from heap.
I googled there is a runtime memory defragmenter in WM2003 by adding a
key in registry: HKCU\Software\Microsoft\Shell\NeverDorkMemory
It does not work in Windows CE 5.0!
Do you have any ideas?
Thanks,
On 10$B7n(B20$BF|(B, $B2<8a(B5$B;~(B25$BJ,(B, "Luca Calligaris"
Post by Luca Calligaris
If your OS includes FATUTIL.DLL you cal call the API DefragVolumeEx
--
Luca Calligariswww.eurotech.it
Post by paul
Hi,
Is it possible to defragment memory in Windows CE 5.0?
Can somebody give me some points how to do it with Visual Studio 2005?
Thanks,
unknown
2008-10-20 18:16:33 UTC
Permalink
You can call CompactAllHeaps from time to time. It doesn't move things
around (what Paul warned against), just can decommit unused pages. It may
also coalesce free memory blocks, too - not sure. But the heap manager will
do that on it's own typically on calls to HeapFree/LocalFree/free/delete.

But how are you concluding that the problem you are seeing is related to
heap memory fragmentation?
--
Michael Salamone, eMVP
Entrek Software, Inc.
www.entrek.com
Post by paul
Thank you, Luca.
But I checked the MSDN about the API, it is for defragmenting disk.
We want to defragment memory to avoid out of memory error when ask
memory from heap.
I googled there is a runtime memory defragmenter in WM2003 by adding a
key in registry: HKCU\Software\Microsoft\Shell\NeverDorkMemory
It does not work in Windows CE 5.0!
Do you have any ideas?
Thanks,
On 10$B7n(B20$BF|(B, $B2<8a(B5$B;~(B25$BJ,(B, "Luca Calligaris"
Post by Luca Calligaris
If your OS includes FATUTIL.DLL you cal call the API DefragVolumeEx
--
Luca Calligariswww.eurotech.it
Post by paul
Hi,
Is it possible to defragment memory in Windows CE 5.0?
Can somebody give me some points how to do it with Visual Studio 2005?
Thanks,
paul
2008-10-22 07:42:13 UTC
Permalink
We have a camera driver, which use HalAllocateCommonBuffer() function
to allocate about 7 MB of memory for DMA access. To keep the memory
allocated for camera driver, we don’t close camera driver; and then we
get “not enough memory” error if we try to activate video player to
play video clips.

If we don’t use camera driver, video is playing as expected.

From our investigation, memory allocated by some DLL runtimes is not
released instantly after unload the DLL files (delay unload). We have
tried calling CoFreeUnusedLibrariesEx() API, but it does not work.

We suspect the memory is fragmented after running other applications;
the camera driver might not be able to get continuous pages for
function then.
Chris Tacke, eMVP
2008-10-22 12:58:56 UTC
Permalink
I would think you'd permanently set aside the memory for the driver in
CONFIG.BIB so that you're guaranteed to always have the memory and let apps
deal with the fact they have less RAM available rather than trying to run
behind the apps and beg for scraps. Seems like a far more stable way to
ensure your driver always runs.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

"paul" <***@gmail.com> wrote in message news:ef731d01-de9f-481f-b2d5-***@l76g2000hse.googlegroups.com...
We have a camera driver, which use HalAllocateCommonBuffer() function
to allocate about 7 MB of memory for DMA access. To keep the memory
allocated for camera driver, we don’t close camera driver; and then we
get “not enough memory” error if we try to activate video player to
play video clips.

If we don’t use camera driver, video is playing as expected.

From our investigation, memory allocated by some DLL runtimes is not
released instantly after unload the DLL files (delay unload). We have
tried calling CoFreeUnusedLibrariesEx() API, but it does not work.

We suspect the memory is fragmented after running other applications;
the camera driver might not be able to get continuous pages for
function then.
hartmut
2008-12-18 09:30:01 UTC
Permalink
Hi all,
in order to release unused heap memory to the system, you may use
HeapCompact() with the first parameter set to the result value of
GetProcessHeap().
Regards, Hartmut
Post by paul
(...)
From our investigation, memory allocated by some DLL runtimes is not
released instantly after unload the DLL files (delay unload). We have
tried calling CoFreeUnusedLibrariesEx() API, but it does not work.
We suspect the memory is fragmented after running other applications;
the camera driver might not be able to get continuous pages for
function then.
Loading...