Out of Memory

develop environment
IDE: D7
remobject: 8.3.91.1167,
system: win 7
I have see the same problem on remobject’s talk , if client get very big data from server by TDAMemDataTable. the server will raise an Exception. I debug the server’s program. the debug of "out of memory " is from this function TROBinaryMemoryStream.Realloc(var NewCapacity: Longint): Pointer;
{$ENDIF}
const
MemoryDelta = $2000; { Must be a power of 2 }
begin
if (FCapacityIncrement <> 0) and (NewCapacity<>0) then inc(NewCapacity,FCapacityIncrement);
{$IFDEF PATCH_MEMORYSTREAM_REALLOC}
if (NewCapacity > 0) and (NewCapacity <> Position) then
NewCapacity := (NewCapacity + (MemoryDelta - 1)) and not (MemoryDelta - 1);
Result := Memory;
if NewCapacity <> Capacity then
begin
if NewCapacity = 0 then
begin
FreeMem(Memory);
Result := nil;
end else
begin
if Capacity = 0 then
GetMem(Result, NewCapacity)
else
ReallocMem(Result, NewCapacity); — exception is raised here
if Result = nil then raise EStreamError.CreateRes(@SMemoryStreamError);
end;
end;
{$ELSE}
Result := inherited Realloc(NewCapacity);
{$ENDIF}
end;
the caption of exception is " class EOutOfMemory with message ‘Out of memory’. Process stopped. Use Step or Run to continue."
so I Create simple Code like this
procedure TForm1.Button1Click(Sender: TObject);
begin
var
P: Pointer;
i: Integer;
begin
I := High(Integer);

P := GetMemory(I);
ReallocMem(P, I) ;
FreeMem§;
end;
the program will raise the same exception , so i think this exception is raised by delphi , but i don’t know how to solve this problem.

Can specify a bit more details like

  • what size of very big data?
  • how much free memory you have on pc where your app is launched?

you are using Delphi7 so created application can use only 2gb of memory.

what size of very big data?
I Create two clients to get data from same server at the same time. from the windows task manager, I found that the Server’s Memory was over 1.5GB. then the exception was raised

how much free memory you have on pc where your app is launched?
my pc total memory is 8 GB, free memory is over 2GB

Maybe I should update my ide to 64bit. so I can build 64bit process

if this exception raise two many times the server will crash , so I think whay not free the memory when the exception was raised , so I can run a Strong Server

I don’t think, that you should have all this data (i.e. 1,5gb) of data at once on your client.
I can recommend to review possibility to retrieve the required data in small chunks as shown in this sample from DA6.
Fetch.zip (44.4 KB)

Note: some updating may be required because this sample wasn’t updated for ages.

use FastMM to Manager memory, and set option SetPEFlags 20 . this problem can be solved. if some one
want to get more details, please send E-Mail to xx2088@sina.com