Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28632 Discussions

how to measure the maximal required memory

jackmwl
Beginner
309 Views
Is there any way to measure the maximal required memory at runtime, as the elapsed time can be returned by ETIME?

I am trying to optimize the memory requirements, but I donot know if the optimization works.

Thanks a lot!

Best regards

Jack

0 Kudos
2 Replies
Paul_Curtis
Valued Contributor I
309 Views
The Windows API function GlobalMemoryStatus() returns the available and used blocks of physical memory, and can be called from your program to indicate varying memory usage (but the report of used memory includes usage by all currently executing processes, not just your program). As an example,

[bash]!     TYPE T_MEMORYSTATUS
!     SEQUENCE
!       integer(DWORD)		 dwLength		 ! knowns  DWORD 
!       integer(DWORD)		 dwMemoryLoad	 ! knowns  DWORD 
!       integer(POINTER_LEN) dwTotalPhys	 ! knowns  SIZE_T 
!       integer(POINTER_LEN) dwAvailPhys	 ! knowns  SIZE_T 
! integer(POINTER_LEN) dwTotalPageFile ! knowns SIZE_T ! integer(POINTER_LEN) dwAvailPageFile ! knowns SIZE_T ! integer(POINTER_LEN) dwTotalVirtual ! knowns SIZE_T ! integer(POINTER_LEN) dwAvailVirtual ! knowns SIZE_T ! END TYPE
TYPE(T_MEMORYSTATUS) :: ms
CALL GlobalMemoryStatus (ms)
WRITE (yourstring, '("KB Free",I14,A,"KB Total",I12,A)') & ms%dwAvailPhys/1024, crlf, ms%dwTotalPhys/1024, CHAR(0) [/bash]
0 Kudos
jackmwl
Beginner
309 Views
Thanks for your reply, Paul!

I have tested the GlobalMemoryStatus() using allocatable arrays, and found that dwAvailPhys always have the same output and that dwAvailVirtual have bigger and bigger output even after deallocating all the allocated arrays.

Sowhat do the results tell?

Thanks!

Best regards

Jack

0 Kudos
Reply