Click here to Skip to main content
11,805,604 members (60,884 online)
Click here to Skip to main content

Memory Allocation Tool

, 20 Feb 2003 Ms-PL 156.5K 3.4K 67
Rate this:
Please Sign up or sign in to vote.
Simple tool to test applications under various memory conditions.
<!-- Download Links --> <!-- Article image -->

Sample Image - Alloc.jpg


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.

How to use

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. Smile | :)


This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


About the Author

No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
ti_mo_n8-Mar-13 20:37
memberti_mo_n8-Mar-13 20:37 
GeneralVery Good Pin
Vitaly Tomilov5-Sep-08 13:50
memberVitaly Tomilov5-Sep-08 13:50 
GeneralValues are missing Pin
Lokanatha Reddy30-Apr-07 23:36
memberLokanatha Reddy30-Apr-07 23:36 
When i run this tool under win-2k, it showing 'System Catche' as 0 and 'Peak' as 0. But my task manager showing actual values. How to get actual values?

Generalpf usage Pin
welcomsmail2-Mar-07 4:36
memberwelcomsmail2-Mar-07 4:36 
QuestionHow to make allocation sticky? Pin
thebigpixel2-Nov-06 10:14
memberthebigpixel2-Nov-06 10:14 
GeneralIt doesn'nt work under W2K Pin
minouche15-Mar-04 6:39
memberminouche15-Mar-04 6:39 
GeneralAlmost... Pin
Darren Schroeder5-Feb-03 13:59
memberDarren Schroeder5-Feb-03 13:59 
GeneralRe: Almost... Pin
Andreas Saurwein5-Feb-03 23:26
memberAndreas Saurwein5-Feb-03 23:26 
Generalproblem of PSAPI.DLL Pin
sm7730-Jan-03 19:23
membersm7730-Jan-03 19:23 
GeneralRe: problem of PSAPI.DLL Pin
Andreas Saurwein4-Feb-03 0:10
memberAndreas Saurwein4-Feb-03 0:10 
Generalpsapi.dll and getperformanceinfo Pin
thorgrim20-Jan-03 22:49
memberthorgrim20-Jan-03 22:49 
GeneralRe: psapi.dll and getperformanceinfo Pin
Andreas Saurwein20-Jan-03 23:16
memberAndreas Saurwein20-Jan-03 23:16 
GeneralRe: psapi.dll and getperformanceinfo Pin
Andreas Saurwein4-Feb-03 0:09
memberAndreas Saurwein4-Feb-03 0:09 
GeneralCompile Error fatal error RC1015: cannot open include file 'atlres.h' Pin
ink19-Jan-03 23:29
memberink19-Jan-03 23:29 
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pin
Andreas Saurwein20-Jan-03 2:43
memberAndreas Saurwein20-Jan-03 2:43 
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pin
Nascott15-Nov-03 7:01
memberNascott15-Nov-03 7:01 
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pin
SaurweinAndreas15-Nov-03 12:29
memberSaurweinAndreas15-Nov-03 12:29 
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pin
Anonymous19-Feb-05 14:06
sussAnonymous19-Feb-05 14:06 
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pin
mercede23-Jul-08 19:49
membermercede23-Jul-08 19:49 
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pin
rcvf28-Oct-09 7:12
memberrcvf28-Oct-09 7:12 
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pin
sm7730-Jan-03 19:01
membersm7730-Jan-03 19:01 
GeneralSorry, for the not working download. Its fixed. Pin
Andreas Saurwein18-Jan-03 5:07
memberAndreas Saurwein18-Jan-03 5:07 
GeneralCool Pin
Marc Clifton18-Jan-03 3:17
memberMarc Clifton18-Jan-03 3:17 
GeneralRe: Cool Pin
Andreas Saurwein18-Jan-03 5:05
memberAndreas Saurwein18-Jan-03 5:05 
GeneralNice touch at the end... Pin
Kant17-Jan-03 17:41
memberKant17-Jan-03 17:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151002.1 | Last Updated 21 Feb 2003
Article Copyright 2003 by Andreas S. Franci Gonçalves
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid