Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-05

replacement of MemAvail and MaxAvail

9 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to mokashe.ram
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.

Reply by email

Michael Van Canneyt
to mokashe.ram
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.

Reply by email

Karoly Balogh (Charlie/SGR
to mokashe.ram: Thanks For Your This Prompt Reply... but in promgram these functions are already used in…

Hi,

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

Reply by email

Mark Morgan Lloyd
to mokashe.ram: Thanks For Your This Prompt Reply... but in promgram these functions are already used in…
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]

Reply by email

Jonas Maebe
to mokashe.ram: Thanks For Your This Prompt Reply... but in promgram these functions are already used in…
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

Reply by email

waldo kitty
to mokashe.ram: Thanks For Your This Prompt Reply... but in promgram these functions are already used in…
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.

Reply by email