![]() |
Languages »
C / C++ Language »
General
Intermediate
License: The Microsoft Public License (Ms-PL)
Memory Allocation ToolBy Andreas Saurwein Franci GonçalvesSimple tool to test applications under various memory conditions. |
VC6, VC7Win2K, WinXP, WTL, STL, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Sometimes it is very helpful to test your applications in extreme situations like low resources, full hard disk, or low memory conditions.
This tool covers just the last - memory. It allows you to allocate as much memory as might be available.
Run it. The dialog shows the basic memory allocation information like total/available/free memory, both physical and virtual. The view is equal to what you see in the Windows Taskmanager.
The slider has 3 tick marks - the start, the current memory limit and the end. The start means only that no memory at all is allocated. The end is the very end of the theoretical virtual memory which is usually at 2 GB. And the current memory limit is the amount of memory available.
Depending on the OS these values and their meaning may vary. If you have set your system to automatically manage virtual memory, then the current memory limit is variable and the tick will change as you allocate memory.
The minimum allocation size is 1 Megabyte; this is also the line size of the slider. If you press key up/down or left/right the allocation will increase/decrease in steps of 1 Mb. This is useful for fine-tuning available memory. The page size is 16 Mb (using page up/down keys). You can of course also just grab the slider with the mouse and drag it around; the current allocation is immediately shown.
Memory allocation errors or other problems are not shown. If memory can't be allocated, the slider won't update.
The checkbox "Allocate and use" shows different behaviors on different OS. Under Windows NT/2K/XP it will force Windows to actually keep the allocated memory block in memory. Otherwise, memory is allocated but not claimed in memory. If this is not checked you can allocate all available memory and you will not see any change in the physical memory allocation. Windows only claims this memory when you actually access it.
It is written with WTL and STL under VC6 und runs under W2k and XP Pro (probably also under NT4 SP6). The project contains only a debug build and is only MBCS.
This is the promised update for non-Windows XP users. Now the application does no longer require the PSAPI.dll. Instead it emulates the GetPerformanceInfo() function by an internal function which returns almost the same information. The only differences are two values which I could not easily retrieve. These values are the "Commit Peak" and "System Cache" values. Probably you won't miss them anyway.
PS: Don't complain about memory leaks, they are your responsibility. :)
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 20 Feb 2003 Editor: Nick Parker |
Copyright 2003 by Andreas Saurwein Franci Gonçalves Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |