Hi,
A simple question for the excellent people on this forum, how can you determine how much 'ram' is required on a PC to execute a given programme, i guess its to some extent based on array sizes etc...??
Welcome to our forums
Hi,
A simple question for the excellent people on this forum, how can you determine how much 'ram' is required on a PC to execute a given programme, i guess its to some extent based on array sizes etc...??
These days, it is more common to use dynamically allocated arrays -- typically, arrays whose sizes are computed from earlier portions of input data. There is no simple, reliable way of keeping a tally of how much RAM is consumed; in fact, on Usenet comp.lang.fortran there was a very long thread on ideas related to this issue.
You can obtain the sizes of the 'text' and 'data' segments using Dumpbin or the Linux/Cygwin command size:
Q:\lang\mkl>size talmi.exe
text data bss dec hex filename
19138759 106096 0 19244855 125a737 talmi.exe
You can open the Task Manager when the program is still running and look at the memory consumption.
I'd accept that it is more common to use dynamically allocated arrays today in new code, or even if you are messing around with (or 'updating') old code. Mecej4 can probably tell you what goes wrong halfway through that! I had my fingers burnt with allocatable arrays in 1973 (in Algol 60) when the program worked OK when tested, but not with realistic data sets. Once bitten, twice shy. It wasn't Fortran, but after that I always used extremely trimmed-down array sizes and didn't proliferate arrays.
The old Microsoft Fortran had a utility that extracted exactly the sort of information that you are looking for from an EXE file header, but presumably this information is stored somewhere even today, and could be extracted if you need to and can find someone with the skills to extract the data from your EXE
I don't reckon that the RAM consumption is ever much of a problem with an up to date PC, unless you want to manage huge datasets (like John Campbell). For example, everything I ever wrote works fine on a Windows XP laptop with 1Gb, or a Windows 10 32-bit tablet, also with 1 Gb.
I suggest looking in Task Manager at how much free RAM you have before you attempt a trial load of your program as well as when it is running - as Mecej4 suggests. I think that (unless you are like JC) you will be surprised at how little space it uses. Another trick is to work out the sizes of all your REAL8 arrays. Only include INTEGER, REAL4 or COMPLEX if you use a lot of them. Again, I guess the answer will be nowhere near your free capacity. The rest, including executable code is again a lot smaller than you think.
For example, take a 5000x5000 array with REAL*8. That's still only 200Mb - and how many of those do you have?
My guess is that it's a lot smaller than you think. My 16Gb machine runs with 12.2 Gb free, and a lot of the used space is taken up with disk cache and OS plus dribs and drabs that other software loads in advance.
And if it's too small, then buy some more RAM or even a new computer, which turns out much cheaper than struggling unless, of course, you count your time as effectively worthless. I could double the 16Gb in my PC for only £60 currently, and you don't buy much of my time for that! Incidentally, all the components in replacing the innards of an existing computer could cost between £150 - £300 because there's absolutely no point in having too many cores just to run FTN95 programs.
Eddie
Quoted from colt1954 Hi,
A simple question for the excellent people on this forum, how can you determine how much 'ram' is required on a PC to execute a given programme, i guess its to some extent based on array sizes etc...??
This is not a simple question, so not sure how detailed the answer required is, especially for 64-bit .exe.
You can use task manager to get an estimate of the memory in use at any time. This can vary depending on how much memory is initialised or referenced. This basically includes code, and initialised arrays.
With lots of subroutines and local arrays, how much of the stack in use can be estimated, but can be difficult to calculate.
ALLOCATE arrays are a special case, as they don't use physical memory until they are 'used'. Certainly, ALLOCATE arrays are not included in the physical memory allocated until they are both allocated and used.
Also physical memory pages are not allocated until each memory page is referenced, so large allocate arrays can become virtual arrays if used in that way. I have examples of a 16gb allocated array that only uses 1gb of physical memory, although this is a contrived case.
The best answer is to use Task Manager 'Processes' tab (Win 7) and monitor the variation.
Just as a math question, Eddie, 5K by 50K of REAL*8 is 2 gigabytes. Did you mean 5K by 5K?
Yes I did. I've corrected it now. Thanks.
Eddie