I am having some problems allocating a lot of storage in
protected mode and was wondering if someone out there could help
narrow down my search: I suspect my computer rather than the code.
The program simply allocates 60KB blocks in extended storage,
copies from an existing block to the new block, then accesses each
byte of that storage.
The following test program runs to completion without errors,
and returns to the IDE and seems to be fine.
As soon as I try to do something else (move the cursor around
the source) the system locks up with a parity error and has
to be reset (very occasionally I can exit BP without a reset).
Occasionally the program stops part way through with a parity error,
again causing a reset.
Is there some brave soul out there that could try this program
and let me know if it fails on their machine too? You will need
at least 10 megs of ram. If indeed the code is at fault, you might
get a parity error as well.
Thanks,
program wptest;
uses crt, winapi;
const
pagesize = 60 * 1024;
type
page = array[1 .. pagesize] of byte;
pageptr = ^ page;
pagevec = array[1 .. 16000] of pageptr;
{ 60K per page, 16,000 pages, should be able to allocate
960,000K bytes }
var
pages : ^ pagevec;
pagect : word;
function
pagealloc : boolean;
{---------
allocate one page, the next page, pagect }
begin
inc(pagect);
pages^[pagect] := globalallocptr(gmem_fixed, pagesize);
if pages^[pagect] = nil then begin
pagealloc := false;
exit;
end;
end;
procedure
ramtest;
{-------
find out why cannot allocate all of ram }
var
i : word;
begin
new(pages);
if not pagealloc then begin
writeln('pagealloc failed on first try');
exit;
end;
for i := 1 to pagesize do
pages^[1]^[i] := byte(i);
while pagect < 128 do begin
pagealloc;
pages^[pagect] := pages^[1];
for i := 1 to pagesize do
if pages^[pagect]^[i] <> pages^[1]^[i] then begin
writeln('mismatch on compare ', pagect:8, i:8);
exit;
end;
writeln(pagect:5, memavail:10);
end;
end;
begin
ramtest;
end.
--
Brent Beach, Victoria, BC