Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: User breakpoint called from code at 0x77f813b1 Pin
Jelahd9-Aug-07 6:02
Jelahd9-Aug-07 6:02 
AnswerRe: User breakpoint called from code at 0x77f813b1 Pin
Stephen Hewitt9-Aug-07 20:07
Stephen Hewitt9-Aug-07 20:07 
QuestionDialogBar problem Pin
Aamol M8-Aug-07 23:24
Aamol M8-Aug-07 23:24 
AnswerRe: DialogBar problem Pin
KaЯl8-Aug-07 23:40
KaЯl8-Aug-07 23:40 
GeneralRe: DialogBar problem Pin
Aamol M8-Aug-07 23:55
Aamol M8-Aug-07 23:55 
GeneralRe: DialogBar problem Pin
KaЯl9-Aug-07 0:11
KaЯl9-Aug-07 0:11 
GeneralRe: DialogBar problem Pin
Aamol M9-Aug-07 0:53
Aamol M9-Aug-07 0:53 
Question[Help] Out of memory Pin
Pogo Lin8-Aug-07 23:20
Pogo Lin8-Aug-07 23:20 
Hi all,

Recently, I have encountered a problem and I tried to debug it. I found that system throw out a CMemoryException when I try to allocate 256MB memory.

I have a member function in one class . see the below list.



ClassA:ClassA()<br />
<br />
{<br />
<br />
...<br />
<br />
mImage = NULL;<br />
<br />
...<br />
<br />
}<br />
<br />
ClassA:~ClassA()<br />
<br />
{<br />
<br />
    delete []mImage;<br />
<br />
}<br />
<br />
bool ClassA : FuncA()<br />
<br />
{<br />
<br />
...<br />
    try<br />
    {<br />
<br />
unsigned long* mImage = new unsigned long[67108864]; // 64M*4 = 256MByte<br />
 <br />
    }<br />
    catch( CMemoryException* pEX)<br />
    {<br />
        CString cstmp;<br />
        CString csOut;<br />
        MEMORYSTATUS stat;        <br />
        GlobalMemoryStatus (&stat); <br />
       <br />
        cstmp.Format("The MemoryStatus structure is %ld bytes long.\n",stat.dwLength);<br />
        csOut+=cstmp;<br />
        cstmp.Format("It should be %d.\n", sizeof (stat));<br />
        csOut+=cstmp; <br />
        cstmp.Format("%ld percent of memory is in use.\n",stat.dwMemoryLoad);<br />
        csOut+=cstmp;<br />
        cstmp.Format("There are %7d total Kbytes of physical memory.\n",stat.dwTotalPhys/ 1024);<br />
        csOut+=cstmp;<br />
        cstmp.Format("There are %7d free Kbytes of physical memory.\n",stat.dwAvailPhys/1024);<br />
        csOut+=cstmp;<br />
        cstmp.Format ("There are %7d total Kbytes of paging file.\n",stat.dwTotalPageFile/1024);<br />
        csOut+=cstmp;<br />
        cstmp.Format("There are %7d free Kbytes of paging file.\n",stat.dwAvailPageFile /1024);<br />
        csOut+=cstmp;<br />
        cstmp.Format("There are %7x total Kbytes of virtual memory.\n",stat.dwTotalVirtual/1024);<br />
        csOut+=cstmp; <br />
        cstmp.Format("There are %7x free Kbytes of virtual memory.\n",stat.dwAvailVirtual/1024);<br />
        csOut+=cstmp;<br />
        pEx->Delete();<br />
        AfxMessageBox(csOut); <br />
    }<br />
...<br />
}



When I called FuncA() to allocate memory and if I called another function beforre, system will throw out CMemoryException.

But if I called FuncA() to allocate memory and I don't called another function, sysem will not throw out CMemoryException.

When system throw out CMemoryException, I tried to print out the usage status of memory.

The result is as below

The MemoryStatus structure is 32 bytes long.
It should be 32.
36 percent of memory is in use.
There are 2096100 total Kbytes of physical memory.
There are 1321288 free Kbytes of physical memory.
There are 4041780 total Kbytes of paging file.
There are 3615048 free Kbytes of paging file.
There are 1fff80 total Kbytes of virtual memory.
There are 70e94 free Kbytes of virtual memory.

I think system has enough memory but I can't allocate successfully.Why? Could anybody give me some suggestions? Just like adjust some parameters for complier or OS.


Regards,
Pogo
AnswerRe: [Help] Out of memory Pin
Iain Clarke, Warrior Programmer8-Aug-07 23:28
Iain Clarke, Warrior Programmer8-Aug-07 23:28 
GeneralRe: [Help] Out of memory Pin
Pogo Lin9-Aug-07 17:49
Pogo Lin9-Aug-07 17:49 
QuestionRe: [Help] Out of memory Pin
David Crow9-Aug-07 3:27
David Crow9-Aug-07 3:27 
AnswerRe: [Help] Out of memory Pin
Pogo Lin9-Aug-07 17:51
Pogo Lin9-Aug-07 17:51 
QuestionAbout outlook [modified] Pin
faulfish8-Aug-07 23:06
faulfish8-Aug-07 23:06 
QuestionRe: About outlook Pin
David Crow9-Aug-07 3:36
David Crow9-Aug-07 3:36 
Questionpassing strings Pin
dona jain8-Aug-07 23:03
dona jain8-Aug-07 23:03 
AnswerRe: passing strings Pin
toxcct8-Aug-07 23:27
toxcct8-Aug-07 23:27 
GeneralRe: passing strings Pin
dona jain8-Aug-07 23:33
dona jain8-Aug-07 23:33 
GeneralRe: passing strings Pin
David Crow9-Aug-07 3:38
David Crow9-Aug-07 3:38 
AnswerRe: passing strings Pin
jhwurmbach8-Aug-07 23:37
jhwurmbach8-Aug-07 23:37 
GeneralRe: passing strings Pin
dona jain8-Aug-07 23:40
dona jain8-Aug-07 23:40 
GeneralRe: passing strings Pin
jhwurmbach8-Aug-07 23:43
jhwurmbach8-Aug-07 23:43 
GeneralRe: passing strings Pin
dona jain8-Aug-07 23:46
dona jain8-Aug-07 23:46 
GeneralRe: passing strings Pin
jhwurmbach8-Aug-07 23:55
jhwurmbach8-Aug-07 23:55 
GeneralRe: passing strings Pin
toxcct9-Aug-07 0:17
toxcct9-Aug-07 0:17 
AnswerRe: passing strings Pin
Ranjoy Guha8-Aug-07 23:41
Ranjoy Guha8-Aug-07 23:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.