replacement of MemAvail and MaxAvail

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

replacement of MemAvail and MaxAvail

mokashe.ram
Hi

Could any one help me on the replacement of MemAvail and MaxAvail function in free pascal 32 bit OS(windows 7).

Thanks,

Sudarshan Mokashe
Reply | Threaded
Open this post in threaded view
|

Re: replacement of MemAvail and MaxAvail

Michael Van Canneyt


On Fri, 30 May 2014, mokashe.ram wrote:

> Hi
>
> Could any one help me on the replacement of MemAvail and MaxAvail function
> in free pascal 32 bit OS(windows 7).

These functions have almost no meaning in a modern OS.

They depend on available RAM, OS usage, number of programs currently running,
size of swap file etc.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: replacement of MemAvail and MaxAvail

mokashe.ram
 Thanks For Your This Prompt Reply...
but in promgram these functions are already used in my applcation developed in TP7, sonow i am migration this applcation to free pascal. how can i replace using free pascal?
Reply | Threaded
Open this post in threaded view
|

Re: replacement of MemAvail and MaxAvail

Michael Van Canneyt


On Fri, 30 May 2014, mokashe.ram wrote:

> Thanks For Your This Prompt Reply...
> but in promgram these functions are already used in my applcation developed
> in TP7, sonow i am migration this applcation to free pascal. how can i
> replace using free pascal?

Throw away the code that uses these functions.
It is useless code and will not work correctly anyway.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: replacement of MemAvail and MaxAvail

mokashe.ram
  Ok Thanks Michael ...

Thanks,
Sudarshan Mokashe
Reply | Threaded
Open this post in threaded view
|

Re: replacement of MemAvail and MaxAvail

Karoly Balogh (Charlie/SGR)
In reply to this post by mokashe.ram
Hi,

On Fri, 30 May 2014, mokashe.ram wrote:

>  Thanks For Your This Prompt Reply...
> but in promgram these functions are already used in my applcation developed
> in TP7, sonow i am migration this applcation to free pascal. how can i
> replace using free pascal?

Michael is right, there's no *real* replacement, because modern OSes
handle the memory differently, and the available memory can change
anytime, even between or during the query function itself... But if you
just want to get the code compiled, with the absolute certainity that it
*will* break runtime, you can for MaxAvail just declare a dummy function
which returns High(LongInt); or some other large constant.

For MemAvail, the problem is that some code uses it to allocate all
available memory in one go, this won't work. But you can still declare a
dummy function, which returns 'some amount', so you can get the code
compiled. However, the original functionality what this code does will not
work, or will not work properly.

Charlie
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: replacement of MemAvail and MaxAvail

Mark Morgan Lloyd
In reply to this post by mokashe.ram
On 30/05/2014 11:00, mokashe.ram wrote:
>   Thanks For Your This Prompt Reply...
> but in promgram these functions are already used in my applcation developed
> in TP7, sonow i am migration this applcation to free pascal. how can i
> replace using free pascal?

Don't. In the larger scale of things, people started to realise in the
1970s that application programs which had handled their own memory
management and possibly timesharing (e.g. APL on an IBM S/370) had to be
rewritten as soon as operating systems started to provide virtual memory.

The only reason this wasn't really seen on PCs was that the advent of
virtual memory was accompanied by a gross change in the overall
programming model, so very few people had to deal with unmodified DOS
programs suddenly behaving unpredictably when run on OS/2 or Windows.

So it's entirely in order to report e.g. the amount of heap currently
allocated for debugging purposes, but don't assume that there's a useful
fixed maximum.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: replacement of MemAvail and MaxAvail

Jonas Maebe-2
In reply to this post by mokashe.ram

On 30 May 2014, at 11:37, mokashe.ram wrote:

> but in promgram these functions are already used in my applcation developed
> in TP7, sonow i am migration this applcation to free pascal. how can i
> replace using free pascal?

Set the global variable ReturnNilIfGrowHeapFails to true, and in all places where you checked whether memavail/maxavail was large enough, instead allocate the memory and check whether the returned pointer is different from nil.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: replacement of MemAvail and MaxAvail

wkitty42
In reply to this post by mokashe.ram
On 5/30/2014 5:37 AM, mokashe.ram wrote:
>   Thanks For Your This Prompt Reply...
> but in promgram these functions are already used in my applcation developed
> in TP7, sonow i am migration this applcation to free pascal. how can i
> replace using free pascal?

take them out... what do you need them for? ;)

--
  NOTE: No off-list assistance is given without prior approval.
        Please *keep mailing list traffic on the list* unless
        private contact is specifically requested and granted.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal