Click here to Skip to main content
6,595,444 members and growing! (17,331 online)
Email Password   helpLost your password?
Languages » C / C++ Language » General     Intermediate License: The Microsoft Public License (Ms-PL)

Memory Allocation Tool

By Andreas Saurwein Franci Gonçalves

Simple tool to test applications under various memory conditions.
VC6, VC7Win2K, WinXP, WTL, STL, Dev
Posted:16 Jan 2003
Updated:20 Feb 2003
Views:116,401
Bookmarked:49 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
21 votes for this article.
Popularity: 5.65 Rating: 4.28 out of 5
1 vote, 4.8%
1

2
2 votes, 9.5%
3
6 votes, 28.6%
4
12 votes, 57.1%
5

Sample Image - Alloc.jpg

Introduction

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.

Information

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.

History

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

License

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

About the Author

Andreas Saurwein Franci Gonçalves


Member

Occupation: Web Developer
Location: Brazil Brazil

Other popular C / C++ Language articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 30 (Total in Forum: 30) (Refresh)FirstPrevNext
GeneralVery Good PinmemberVitaly Tomilov14:50 5 Sep '08  
GeneralValues are missing PinmemberLokanatha Reddy0:36 1 May '07  
Generalpf usage Pinmemberwelcomsmail5:36 2 Mar '07  
QuestionHow to make allocation sticky? Pinmemberthebigpixel11:14 2 Nov '06  
GeneralIt doesn'nt work under W2K Pinmemberminouche7:39 15 Mar '04  
GeneralAlmost... PinmemberDarren Schroeder14:59 5 Feb '03  
GeneralRe: Almost... PinmemberAndreas Saurwein0:26 6 Feb '03  
Generalproblem of PSAPI.DLL Pinmembersm7720:23 30 Jan '03  
GeneralRe: problem of PSAPI.DLL PinmemberAndreas Saurwein1:10 4 Feb '03  
Generalpsapi.dll and getperformanceinfo Pinmemberthorgrim23:49 20 Jan '03  
GeneralRe: psapi.dll and getperformanceinfo PinmemberAndreas Saurwein0:16 21 Jan '03  
GeneralRe: psapi.dll and getperformanceinfo PinmemberAndreas Saurwein1:09 4 Feb '03  
GeneralCompile Error fatal error RC1015: cannot open include file 'atlres.h' Pinmemberink0:29 20 Jan '03  
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' PinmemberAndreas Saurwein3:43 20 Jan '03  
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' PinmemberNascott8:01 15 Nov '03  
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' PinmemberSaurweinAndreas13:29 15 Nov '03  
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' PinsussAnonymous15:06 19 Feb '05  
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pinmembermercede20:49 23 Jul '08  
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pinmemberrcvf8:12 28 Oct '09  
GeneralRe: Compile Error fatal error RC1015: cannot open include file 'atlres.h' Pinmembersm7720:01 30 Jan '03  
GeneralSorry, for the not working download. Its fixed. PinmemberAndreas Saurwein6:07 18 Jan '03  
GeneralCool PinmemberMarc Clifton4:17 18 Jan '03  
GeneralRe: Cool PinmemberAndreas Saurwein6:05 18 Jan '03  
GeneralNice touch at the end... PinmemberKant18:41 17 Jan '03  
GeneralRe: Nice touch at the end... PineditorNick Parker19:04 17 Jan '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin 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