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

Mailing lists / fpc-pascal / 2014-05
9 messages · 6 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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
mokashe.ram wroteHi 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.
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?
mokashe.ram wroteThanks 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.
Ok Thanks Michael ...
Thanks,
Sudarshan Mokashe
Thanks For Your This Prompt Reply... but in promgram these functions are already used in…
Hi,
mokashe.ram wroteThanks 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
Thanks For Your This Prompt Reply... but in promgram these functions are already used in…
mokashe.ram wroteThanks 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.
Thanks For Your This Prompt Reply... but in promgram these functions are already used in…
mokashe.ram wrotebut 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
Thanks For Your This Prompt Reply... but in promgram these functions are already used in…
mokashe.ram wroteThanks 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? ;)