Q:Allocating memory in protected mode. 
Author Message
 Q:Allocating memory in protected mode.



Quote:
>I've just trying to make a protected mode program.  I then got this
>problem, which I can rewrite as the program below.

Nicely presented.

Quote:
>Basically, the program I write need to GetMem/allocating variables up to
>100,000 times.  When I try to GetMem 2000 times, it runs OK, without any
>memory leaking.  But when I try to do it more, it just leaks.

AFAICS, you will need 100000*1024 bytes of RAM, which is over 100MB;
I'd be surprised (a) if you have it, (b) if BP7 can access that much.

Quote:
>Any help or pointer is so appreciated...  Thanks.

Try altering HeapLimit, up & down; it may give a clue.
The manual indicates how the number of GetMem is limited, depending
on HeapLimit.

Quote:
>    gotoxy(1,2);
>    writeln('Memory Available : ', MemAvail, ' No : ', i);

     write  ('Memory Available : ', MemAvail, ' No : ', i, ^M);

will do, should save using Crt, and will need a Writeln outside the loop.

--
Dr John Stockton, Surrey, UK



Wed, 18 Jun 1902 08:00:00 GMT  
 Q:Allocating memory in protected mode.
Hi all,

I've just trying to make a protected mode program.  I then got this
problem, which I can rewrite as the program below.

Basically, the program I write need to GetMem/allocating variables up to
100,000 times.  When I try to GetMem 2000 times, it runs OK, without any
memory leaking.  But when I try to do it more, it just leaks.

Any help or pointer is so appreciated...  Thanks.

--------
-Eddy

{******************* The Program ****************************}
uses crt;

const size=4000;

type PArr = ^TArr;
     TArr = Array [1..1024] of byte;

var a:array [1..size] of PArr;
    i:longint;
begin
  clrscr;
  writeln('Memory Before : ', MemAvail);

  { allocating memory }
  for i:=1 to size do
  begin
    GetMem(a[i], SizeOf(TArr));
    gotoxy(1,2);
    writeln('Memory Available : ', MemAvail, ' No : ', i);
  end;

  { deallocating memory }
  for i:=1 to size do
  begin
    FreeMem(a[i], SizeOf(TArr));
    gotoxy(1,2);
    writeln('Memory Available : ', MemAvail, ' No : ', i);
  end;

  writeln('Memory After  : ', MemAvail);
end.



Wed, 18 Jun 1902 08:00:00 GMT  
 Q:Allocating memory in protected mode.

Quote:
> >Basically, the program I write need to GetMem/allocating variables up to
> >100,000 times.  When I try to GetMem 2000 times, it runs OK, without any
> >memory leaking.  But when I try to do it more, it just leaks.
> AFAICS, you will need 100000*1024 bytes of RAM, which is over 100MB;
> I'd be surprised (a) if you have it, (b) if BP7 can access that much.
> >Any help or pointer is so appreciated...  Thanks.
> Try altering HeapLimit, up & down; it may give a clue.
> The manual indicates how the number of GetMem is limited, depending
> on HeapLimit.
> --
> Dr John Stockton, Surrey, UK

Sorry not to put this question right...  What I actually want to know is
whether there is a limit -in protected mode- in the number of calling to
GetMem.

If somebody compile (to protected mode) the code I attached to the
original post, he will get a run time error 203 when the number of calling
to GetMem is about 2000, even though there is still some memory space
left...

I tried it in my Univ's PC, and it stop after 2113 calling to GetMem,
displaying "run time error 203" message, although there is still free 10Mb
memory left.

So the problem persists...

--
-Eddy

ps : I don't think HeapLimit has any effect in protected mode.  Anyway,
thanks for responding...



Wed, 18 Jun 1902 08:00:00 GMT  
 Q:Allocating memory in protected mode.

Quote:

>Basically, the program I write need to GetMem/allocating variables up to
>100,000 times.  When I try to GetMem 2000 times, it runs OK, without any
>memory leaking.  But when I try to do it more, it just leaks.

I don't think it really leaks.  The problem is instead that Memavail
is unreliable in protected mode.

However, you should be aware that an allocation can fail in pmode even
if memory is available - you need to have enough handles available,
and I think you only get around 2000 in a typical run.  Each handle is
used by a block of memory; allocations take a whole block if they're
large, or part of a block if they're small.  You might want to look in
the manual at the memory manager variables HeapXXXX to tune things and
get your program to work.

Duncan Murdoch



Wed, 18 Jun 1902 08:00:00 GMT  
 Q:Allocating memory in protected mode.


Quote:

}> The manual indicates how the number of GetMem is limited, depending
}> on HeapLimit.
}ps : I don't think HeapLimit has any effect in protected mode.  ...

BP7 language guide, para spanning pp.268-9 : Oh yes it does.  And I've
seen it make a difference.  It may not affect you now, but The [late &
lamented] Pascal Magazine advised setting to 0 for testing, to give a
better chance of getting an Error 216 when you deserve one at the cost
of allowing fewer items on the Heap - my words, not theirs.  Did me good!
--
Dr John Stockton, Surrey, UK


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Allocating memory under protected mode (BP7)

2. Graphic Memory Access in Protected Mode

3. Protected mode: Writing to and executing in memory

4. protected mode memory manager question

5. Question: Physical memory access in DOS protected mode

6. How to access memory below 1M in 32-bit protected mode

7. Protected Mode Memory Manager Problem

8. Protected mode & memory access (BP7)

9. BP 7 Protected mode memory manager error

10. Funny action on memory alloc in protect mode

11. Need to Access directly to Vga Memory in protected mode

12. Continuous memory >64kb in Protected Mode

 

 
Powered by phpBB® Forum Software