Solved

getting out of memory errors at 400MB size when computer has 4G on XP

Posted on 2008-06-23
7
551 Views
Last Modified: 2013-11-20
Hi,
I thought the heap was supposed to just increase indefinitely, but I have a program that generates an "Out of Memory" error at 400MB when the computer has a 4GB. Its running on XP pro, developed with VC++ 6.0 MFC. Any ideas?
 
0
Comment
Question by:longtree
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:wayside
ID: 21848057
What is your program doing when you get the error? Are you allocating memory? If so, how much?

Do you have a fixed size pagefile or do you let Windows dynamically manage the size?

How much virtual address space is your program using? On 32 bit Windows you are limited to 1 Gb of user space, IIRC.
0
 

Author Comment

by:longtree
ID: 21849622
I am not sure exactly what the program is doing when it gets the error. My program is only a DLL that runs on a trading engine.
The program runs for a while and every few seconds seems to allocate a few more Megs until it reaches 400MB or so and crashes.
I used leakfinder (http://www.codeproject.com/KB/applications/leakfinder.aspx) to look at the heap at different time points and I couldn't find something obvious that was eating up space.

The paging file size is 5000MB and its managed by windows. In terms of address space its a typical 32bit MFC program ... so nothing out of the ordinary as far as I can tell.

0
 

Author Comment

by:longtree
ID: 21850691
I tracked it with process explorer. When it pops up with the out of memory dialog box, the state of the memory is:

working set 378,284 k (physical memory)

private bytes 560,604k (virtual memory).

virtual size 2,078,592k

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 14

Accepted Solution

by:
wayside earned 250 total points
ID: 21855481
> virtual size 2,078,592k

There's your problem. A 32 bit process on Windows can only allocate 2 Gb of user space of the theoretical 4 Gb maximum address space, and the process has grabbed it all. This is independent of how much physical memory the process is actually using (the rest is stored in the pagefile).

You have some kind of massive memory leak somewhere.

I'm assuming this doesn't happen if the program runs without your dll?
0
 

Author Comment

by:longtree
ID: 21857088
The private bytes is the actual virtual memory used .. so why is the virtual size 2G?
0
 
LVL 14

Expert Comment

by:wayside
ID: 21857392
Private bytes is not the same as virtual memory used. Private bytes is the amount of virtual memory that only your process can access, and (I believe) has been been committed. It doesn't include things like the executable portions of the process or mapped files, etc.

IIRC, VirtualAlloc() calls can comsume virtual address space without affecting private bytes,
0
 

Author Comment

by:longtree
ID: 21861967
I found a significant memory leak. Seems to be working now. Tnx for the support!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now