Solved

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

Posted on 2008-06-23
7
558 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 124
Pressing cancel button with C# UI Automation 3 52
sameEnds challenge 3 135
format the code in java 6 86
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…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

19 Experts available now in Live!

Get 1:1 Help Now