Solved

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

Posted on 2008-06-23
7
564 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 101
ODBC Connection Logging, ADO.NET 6 69
Is there a simple front-end menu system. 9 105
x-bar in Google Sheets 2 72
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

820 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