Board index » delphi » Heap Problem in Turbo Pascal 1.5 on Win95

Heap Problem in Turbo Pascal 1.5 on Win95

I am writing program in Turbo Pascal ver1.5 under windows  95, but I
need to use some big pointer arrays allocated memory more than 64K
limit. So I delcare the following code:
type heaparr=arrary[0..n,0..n) of integer;
arrpt =^heaparr;
var
    newf:arrpt;
....
....
   new(newf);
  ....
dispose(newf);
...
The program can run no problem if run under dos (using turbo pascal 7)
but when I run under win95, general protection fault message is
displayed and need to quit the program.
How should I do to acheive this by using memory on heap under win95?
Thanks
 

Re:Heap Problem in Turbo Pascal 1.5 on Win95


Quote
> I am writing program in Turbo Pascal ver1.5 under windows  95, but I
> need to use some big pointer arrays allocated memory more than 64K
> limit. So I delcare the following code:
> type heaparr=arrary[0..n,0..n) of integer;
> arrpt =^heaparr;
> var
>     newf:arrpt;
> ....
> ....
>    new(newf);
>   ....
> dispose(newf);
> ...

First read the FAQ on the question how to use more than 64 K
memory.!!!!!!!!
The way you are declaring it will still give you not more than the
maximum blocksize of 64 k .

A general protection fault typically happens in windows or protedted mode
for the only reason that you are trying to access something outside the
defined boundaries of your array. In pointer arrays the range checking
does not always warn you for this.
In TP for DOS this will not always result in an error, due to accidently
writing to an empty piece of memory.
Tips:
Try to find the point in the program where the crash occurs!
Very thoroughly check all code involving  arrpt.
most likely:
when assigning values to elements of  newf check that the indexes are not
out of range
e.g.  newf^[i,j]:=X;  {check i and j}
check that no value assignments are made before you called >    new(newf)
or after > dispose(newf);
Check that new and dispose are called only once.

Write a very small test program yust only for trying out the use of
pointers. If that all does not work, send us a piece of code.

Femme

Other Threads