Board index » delphi » override 64k mem limit???

override 64k mem limit???

It seems, as you can not take more variables than 64kb.Is there there a way
to access more memory?
Any help would be greatly appreciated...
-T. Stoffels
 

Re:override 64k mem limit???


Quote
"T. S." wrote:

> It seems, as you can not take more variables than 64kb.Is there there
> a way to access more memory?

use the heap, look for New and Dispose and Getmem and Freemem in your
manuals.

http://www.geocities.com/SiliconValley/2926/tpf.html
page "FAQ", article "Turbo Pascal Memory considerations, pointer primer"
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
------------------------------------------------------------------------
http://members.eunet.at/meg-glaser/           mailto:meg-gla...@eunet.at
http://www.geocities.com/~franzglaser/ http://members.xoom.com/f_glaser/

Re:override 64k mem limit???


Quote
T. S. wrote:

> It seems, as you can not take more variables than 64kb.Is there there a way
> to access more memory?
> Any help would be greatly appreciated...
> -T. Stoffels

You have do initialize your variables on the heap! For that, you must
use pointers! Using the heap, you cann access all the available memory
(up to 640kB in real mode, all memory in protected mode).

Example (just using a big array, you can do this with every var!):
type myarray = array[ 0.. 60000 ] of byte;  
var  p       : ^myarray;
Begin
 new( p );  <- This reserves the memory (heap) for this array
 ...
 p^[0] := 255; <- do anything with p! You just have to use p^
                  instead of p!
 dispose( p ); <- Don't forget to relese the memory at the end
End.

regards
--
Arno Fehm (af...@bigfoot.de)

------------------------------------------------------------------------
Member of Grey Dreams Design: visit http://GreyDreams.home.pages.de !!!!
He who can destroy a thing has the real control over it. (Frank Herbert)
------------------------------------------------------------------------

Re:override 64k mem limit???


In article <37162B55.73E1...@bigfoot.de>, Arno Fehm  <af...@bigfoot.de> wrote:

Quote
>T. S. wrote:

>> It seems, as you can not take more variables than 64kb.Is there there a way
>> to access more memory?
>> Any help would be greatly appreciated...
>> -T. Stoffels
>You have do initialize your variables on the heap! For that, you must
>use pointers! Using the heap, you cann access all the available memory
>(up to 640kB in real mode, all memory in protected mode).

>Example (just using a big array, you can do this with every var!):
>type myarray = array[ 0.. 60000 ] of byte;  
>var  p       : ^myarray;
>Begin
> new( p );  <- This reserves the memory (heap) for this array
> ...
> p^[0] := 255; <- do anything with p! You just have to use p^
>                  instead of p!
> dispose( p ); <- Don't forget to relese the memory at the end

There is no need to release the memory at the end. You need to release
only if you want to reuse the memory within the program.

Quote
>End.

>regards

Osmo

Re:override 64k mem limit???


Quote
Osmo Ronkanen wrote:
> >Example (just using a big array, you can do this with every var!):
> >type myarray = array[ 0.. 60000 ] of byte;
> >var  p       : ^myarray;
> >Begin
> > new( p );  <- This reserves the memory (heap) for this array
> > ...
> > p^[0] := 255; <- do anything with p! You just have to use p^
> >                  instead of p!
> > dispose( p ); <- Don't forget to relese the memory at the end
> There is no need to release the memory at the end. You need to release
> only if you want to reuse the memory within the program.

Well, I DO think, there is a need: Programming style!
Just put this into a procedure and if you forget the dispose... you soon
will get into big problems...
Probably not YOU, but ME or someone else!

regards
--
Arno Fehm (af...@bigfoot.de)

------------------------------------------------------------------------
Member of Grey Dreams Design: visit http://GreyDreams.home.pages.de !!!!
He who can destroy a thing has the real control over it. (Frank Herbert)
------------------------------------------------------------------------

Re:override 64k mem limit???


Quote
Osmo Ronkanen wrote:
> There is no need to release the memory at the end. You need to release
> only if you want to reuse the memory within the program.

Why? Is it released automatically at the end of the program? Is there
a difference between real and protected mode regarding this?

Re:override 64k mem limit???


Quote
In article <371850F9.5A157...@home.ivm.de>, Frederic  <f...@home.ivm.de> wrote:
>Osmo Ronkanen wrote:

>> There is no need to release the memory at the end. You need to release
>> only if you want to reuse the memory within the program.

>Why? Is it released automatically at the end of the program? Is there
>a difference between real and protected mode regarding this?

It is released in both cases. In fact in real mode the DOS knows nothing
on what is allocated and what is not, the entire program, is one
allocation in real mode.

Osmo

Re:override 64k mem limit???


In article <37183B27.CC9BF...@bigfoot.de>, Arno Fehm  <af...@bigfoot.de> wrote:

Quote
>Well, I DO think, there is a need: Programming style!
>Just put this into a procedure and if you forget the dispose... you soon
>will get into big problems...
>Probably not YOU, but ME or someone else!

Well at least I know when I put something in a procedure and when not.
When the issue is extending global variables by the use of heap then
there is no need to release.

Osmo

Other Threads