Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ReallocMem produces Out Of Memory, but mem is available

Status
Not open for further replies.

ToTheMetal

Programmer
Apr 10, 2005
4
0
0
US
The problem is in a purchased control and the original developer is no longer to be found.

The basic problem is the following code from the control:
Code:
procedure TPline.SetCapacity(NewCapacity: Integer);
begin
  if (NewCapacity < FCount) or (NewCapacity > MaxVertexListSize) then
    Error('TPline.SetCapacity: Index out of bounds');
  if NewCapacity <> FCapacity then
  begin
    ReallocMem(FData, NewCapacity*FDimension*SizeOf(Double));
    FCapacity := NewCapacity;
  end;
end;

When [tt]NewCapacity[/tt] is 128256 I get "project mte1_4.exe raised exception class EOutOfMemory with message 'Out of memory'. Process stopped. Use Step or Run to continue." when running in the Delphi 7 IDE.

I have tons of physical and virtual memory available according to Windows, so I don't know why I am getting this error. I researched everything I could find about heap and stack limitations and found nothing useful yet.

Here are some more details that might help:

[ol]
[li]The allocation increment is 128 items, which translates into 128 * 3 * sizeof(Double) = 128 * 24 = 512 bytes.[/li]
[li][tt]FCount[/tt] is 128128 and [tt]NewCapacity[/tt] is 128256 when the error occurs.[/li]
[li][tt]MaxVertexListSize[/tt] is 268435454[/li]
[li]The process is using 35,604K of memory when the error occurs, according to the Windows Task Manager.[/li]
[li]523244 Physical memory total, 131872 Physical memory available when the error occurs, according to Windows Task Manager.[/li]
[/ol]

Any suggestions or constructive criticisms are welcome and no offense will be taken if I am overlooking something obvious! [blush]

-Doug
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top