- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
I am trying to optimize the memory requirements, but I donot know if the optimization works.
Thanks a lot!
Best regards
Jack
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
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
![](/skins/images/8B6E2C8F64F54CBD7F7262AA46F575DA/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page