473,788 Members | 3,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Increasing contiuous memory block available fpr MFC application

I have seen in various posts that there are tricks to increasing the
largest continuous memory block available to an application on a
windows machine. I want to prove this is possible using a simple
example.

Here is my configuration.

-I am running vc++ 6.0 on winXP. (Came with book Starting with Visual
C++ by Wright)
-I have the 3GB switch set at run time
-I have the /largeaddressawa re option set during the link
-I am using Virtual Memory Validator to see the largest memory block.
Free!!

Here is a very simple application from the book on page 385. It just
opens a window.

When this simple example is executed, the largest block available is
~1,190MB. I want to see if I can increase it.

From a post I got the following hint:
"Finally, the extra memory is not in a contiguous block with the
memory
below 2Gb, because msvcrt.dll, kernel32.dll, etc, load just below the
2Gb
line. However, the C/C++ run-time library will happily allocate memory
above 3Gb. In fact, it will seek out all the free memory available,
provided that you request it in small enough chunks that it can fit
them
into the available places in the address space that haven't got code
in
them."

The c++ code that opens up the hello window is given below. Please
show me how to modify it so that I can significantly increase the
memory block. I will make sure to provide the group detailed
instructions as to how to do this once I have succeeded.

thanks!! Here is the VC++ code for the hello window:

// HelloMFC.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "HelloMFC.h "

#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CHelloMFCApp

BEGIN_MESSAGE_M AP(CHelloMFCApp , CWinApp)
//{{AFX_MSG_MAP(C HelloMFCApp)
ON_COMMAND(ID_A PP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP ()

/////////////////////////////////////////////////////////////////////////////
// CHelloMFCApp construction

CHelloMFCApp::C HelloMFCApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CHelloMFCApp object

CHelloMFCApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CHelloMFCApp initialization

BOOL CHelloMFCApp::I nitInstance()
{
AfxEnableContro lContainer();

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

#ifdef _AFXDLL
Enable3dControl s(); // Call this when using MFC in a shared DLL
#else
Enable3dControl sStatic(); // Call this when linking to MFC statically
#endif

// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey( _T("Local AppWizard-Generated Applications")) ;
// To create the main window, this code creates a new frame window
// object and then sets it as the application's main window object.

CMainFrame* pFrame = new CMainFrame;
m_pMainWnd = pFrame;

// create and load the frame with its resources

pFrame->LoadFrame(IDR_ MAINFRAME,
WS_OVERLAPPEDWI NDOW | FWS_ADDTOTITLE, NULL,
NULL);


// The one and only window has been initialized, so show and update
it.
pFrame->ShowWindow(SW_ SHOW);
pFrame->UpdateWindow() ;

return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CHelloMFCApp message handlers

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAbo utDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(C AboutDlg)
protected:
virtual void DoDataExchange( CDataExchange* pDX); // DDX/DDV
support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAbou tDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE _MAP()
};

CAboutDlg::CAbo utDlg() : CDialog(CAboutD lg::IDD)
{
//{{AFX_DATA_INIT (CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDa taExchange(CDat aExchange* pDX)
{
CDialog::DoData Exchange(pDX);
//{{AFX_DATA_MAP( CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_M AP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(C AboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP ()

// App command to run the dialog
void CHelloMFCApp::O nAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModa l();
}

/////////////////////////////////////////////////////////////////////////////
// CHelloMFCApp message handlers
Jul 22 '05 #1
1 2434
On 19 Nov 2004 17:29:23 -0800, je************* **@hotmail.com (picard)
wrote in comp.lang.c++:
I have seen in various posts that there are tricks to increasing the
largest continuous memory block available to an application on a
windows machine. I want to prove this is possible using a simple
example.


[big snip of off-topic code]

Then you need to ask about it in a Windows programming group like
news:comp.os.ms-windows.win32.p rogrammer.

Neither "MFC" nor the phrase "windows(si c) machine" are defined by
C++.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
7433
by: Bryan Rickard | last post by:
I wrote a simple program in VB6 to copy all the files from a directory on a CD-ROM to my hard disk. There are about 10 files, each about 30MB. The program uses Get and Put to get data from the CD into a buffer and then put it into the disk. See code below. It works, but it slows down drastically before it copies all the files. Windows Task Manager shows the CPU usage gradually increasing as the files are copied, until it reaches 100...
18
6681
by: Tron Thomas | last post by:
Given the following information about memory management in C++: ----- The c-runtime dynamic memory manager (and most other commercial memory managers) has issues with fragmentation similar to a hard drive file system. Over time, the more often use call new/delete or alloc/free, there will be gaps and fragments in the heap. This can lead to inefficient use of available memory, as well as cache-hit inefficiencies.
100
3649
by: jacob navia | last post by:
As everybody knows, C uses a zero delimited unbounded pointer for its representation of strings. This is extremely inefficient because at each query of the length of the string, the computer starts an unbounded memory scan searching for a zero that ends the string. A more efficient representation is: struct string {
0
3907
by: Frank Lopez | last post by:
Does anyone know if Microsoft generated a whitepaper on this topic? Does anyone know what the solution is? (meaning, eliminate the leak problem -- I am seeing three memory leaks from dllmodul.cpp(102) similar to what is mentioned below)... I am calling MFC as part of unmanaged code used by the managed code. +--------
6
1777
by: Tina | last post by:
My asp.net app that ran fine on my dev boxes is having problems at my web hoster who is running IIS 6. I'm getting Out of Memory exceptoions. When my web hoster bounces my app, the problem goes away for a couple of days. Sounds like I have a Memory Leak, but my application is managed and garbage collection is automatic, right? How can I track available memory and what kinds of tools are available to shoot this kind of problem? Thanks,...
13
6168
by: hurry | last post by:
In order to avoid declaring static variables in a function I was asked to write a scratch memory. Reserve a block of memory outside the function and assigning pointers to the memory locations as per convenience and access them. I was told this would save some memory. I dont understand the logic behind this, as i`ve declared variables as global (assuming i`ve declared the block in main() ) this would always b a residual data for access at...
62
17858
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image(); img.src = ; Then I use the image a few more times by adding it into an Array object:
4
13891
by: pberent | last post by:
I am trying to run a c# program which loads very large arrays (total of about 1.2GB). I have 2GB of RAM on my machine and looking at task manager it doesnt look like it has all been used. I have set virtual memory (ie disk space to be used as RAM) to 3070MB. I have tested my RAM using a RAM testing utility and it seems fine. I am getting an out of memory error. I started by using visual c# 2002 but someone told me that it was buggy so I...
5
24811
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS (I am new to Windows so not sure). We are currently bouncing the instance to overcome this error. This generally happen at the end of business day only (So maybe memory might be getting used up?). We have already increased the statement heap & ...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.