Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

Out of virtual memory....

Intel_C_Intel
Employee
687 Views
Hi,
I'm having great problems with a fortran code using dynamic allocation
and deallocation. Well, it seems that windows doesn't release the
memory deallocated. This causes my code to stop due to lack of virtual
memory. By following the code i have seen that the memory continously increases as the code runs.
Some people I've talked to claim that this may well happen in
windows2000, especially when using recursive subroutines (but only local variables)... Is this true???
I would very much appreciate an answer, since i'm stuck and going mad....
Best regards /M.
0 Kudos
5 Replies
Steven_L_Intel1
Employee
687 Views
When you deallocate memory in a program that is still running, the memory goes into a pool for possible future allocations - it does not get returned to the operating system. This shouldn't be a problem unless your program contains memory leaks - allocating memory and then losing the pointer rather than deallocating it.

Recursive routines shouldn't be an issue by themselves. There's not enough information in your message to know what's really going on.

Steve
0 Kudos
Intel_C_Intel
Employee
687 Views
Hi,
Thanx for your answer Steve. So, the memory deallocated is kept for later use.
Then, I guess using the Windows Performace Monitor is not a very good idea when trying to find the places in the code where the Virtual Memory increases....??

When i go through a subroutine performing iterations, the Virtual Memory
shown in the Windows Performance Monitor increases with about 600 kB.
At the same time the routine GlobalMemoryStatus tells me that the Virtual Memory used is constant. I use the following lines:

write(*,*) 'Virtual Memory: ', lpMstMemStat.dwTotalVirtual - lpMstMemStat.dwAvailVirtual

What is happening????? Have I missunderstood the use of GlobalMemoryStatus??
Best /M.
0 Kudos
Steven_L_Intel1
Employee
687 Views
All I can tell you is that from Windows' perspective, VM use will never go down while your program is executing. If you do an ALLOCATE and there is not enough free space in the Fortran RTL's pool, it will ask Windows for more memory and the usage will go up. But if you freed memory earlier and do another allocate, then the previously freed memory is reused if possible. Windows doesn't see this.

Once your program exits, all VM allocated is freed to Windows.

Steve
0 Kudos
Intel_C_Intel
Employee
687 Views
Hi,
well i've got that... but I want to trace the memory used by my code.
Could u give me any alternatives. As I wrote before I have tried the
routine GlobalMemoryStatus, but it's highly unstable and doesn't help me when
stepping through the code in the debugger. If I run the code twice the GlobalMemoryStatus return different amount of changes in the memory at different positions....and unfortunately never at an explicit ALLOCATE statement.
Sometimes the memory increases at a normal arithmetic expression, for instance when multiplying a single number with a vector element....
So for me the GlobalMemoryStatus routine seems useless.
Is there anyway I can follow the memory used by my application in real time (when using the debugger) without any impact of where I place my breakpoints???????????????
Thanks
/M.
0 Kudos
Steven_L_Intel1
Employee
687 Views
Sorry, I don't have any suggestions for you here.

Steve
0 Kudos
Reply