Solved

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

Posted on 2008-06-23
7
565 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
withoutTen challenge 14 141
Sed question 2 139
Change to event 1 138
Way to decrease size of apk file 9 132
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

739 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