- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Is there any bulid in function or subroutine avaliable in fortran or other methods to query thememory?
thanks,
コピーされたリンク
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
is catch any error:
allocate( array(10**8), stat = ierr )
if ( ierr /= 0 ) then
write(*,*) 'Oops, allocation failed!'
endif
Regards,
Arjen
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
1) Does the allocation have available Virtual Memory addresses.
2) Does the system have available physical memory.
When an allocation runs out of physical memory, but has Virtual Memory addresses available, the allocation will succeed (provided paging file capacity is not limited and has sufficient disk space for expansion). An application programmer may wish to not exceed the physical memory capacity as this would impact performance.
Other than for allocation failure, Fortran does not have a built-in function for making this determination (near exceeding physical memory capacity, and/or near exceeding page file capacity, and/or near exceeding virtual memory capacity). However, the allocations in Fortran usually interface to the C Runtime Library and the Operating System Heap Manager Library. These libraries usually do have query functions to determine capacities of these natures. Start with searching MSDN for heap management functions (same for Linux if you want portability).
Jim Dempsey
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Thereis more to itthan if an allocation will succeed or fail. You (the programmer) may also be interested in ifthe allocation will place the application into a paging state. (iow when physical memory is occupied while page file and virtual memory as room for additional allocations).
For example, one might want to use:
void GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer );The MEMORYSTATUS structure contains information about the current state of both physical and virtual memory. The GlobalMemoryStatus function stores information in a MEMORYSTATUS structure.
typedef struct _MEMORYSTATUS {
DWORD dwLength;
DWORD dwMemoryLoad;
SIZE_T dwTotalPhys;
SIZE_T dwAvailPhys;
SIZE_T dwTotalPageFile;
SIZE_T dwAvailPageFile;
SIZE_T dwTotalVirtual;
SIZE_T dwAvailVirtual; } MEMORYSTATUS,
*LPMEMORYSTATUS;Members
- dwLength
- Size of the MEMORYSTATUS data structure, in bytes. You do not need to set this member before calling the GlobalMemoryStatus function; the function sets it.
- dwMemoryLoad
- Number between 0 and 100 that specifies the approximate percentage of physical memory that is in use (0 indicates no memory use and 100 indicates full memory use).
WindowsNT:Percentage of approximately the last 1000 pages of physical memory that is in use.
- dwTotalPhys
- Total size of physical memory, in bytes.
- dwAvailPhys
- Size of physical memory available, in bytes.
- dwTotalPageFile
- Size of the committed memory limit, in bytes.
- dwAvailPageFile
- Size of available memory to commit, in bytes.
- dwTotalVirtual
- Total size of the user mode portion of the virtual address space of the calling process, in bytes.
- dwAvailVirtual
- Size of unreserved and uncommitted memory in the user mode portion of the virtual address space of the calling process, in bytes.
Remarks
MEMORYSTATUS reflects the state of memory at the time of the call. It reflects the size of the paging file at that time. The operating system can enlarge the paging file up to the maximum size set by the administrator.
On computers with more than 4 GB of memory, the MEMORYSTATUS structure can return incorrect information. Windows reports a value of -1 to indicate an overflow, while Windows NT reports a value that is the real amount of memory, modulo 4 GB. If your application is at risk for this behavior, use the GlobalMemoryStatusEx function instead of the GlobalMemoryStatus function.
BOOL GlobalMemoryStatusEx( LPMEMORYSTATUSEX lpBuffer );typedef struct _MEMORYSTATUSEX {
DWORD dwLength;
DWORD dwMemoryLoad;
DWORDLONG ullTotalPhys;
DWORDLONG ullAvailPhys;
DWORDLONG ullTotalPageFile;
DWORDLONG ullAvailPageFile;
DWORDLONG ullTotalVirtual;
DWORDLONG ullAvailVirtual;
DWORDLONG ullAvailExtendedVirtual; } MEMORYSTATUSEX,
*LPMEMORYSTATUSEX;Members
- dwLength
- Size of the structure, in bytes. You must set this member before calling GlobalMemoryStatusEx.
- dwMemoryLoad
- Number between 0 and 100 that specifies the approximate percentage of physical memory that is in use (0 indicates no memory use and 100 indicates full memory use).
- ullTotalPhys
- Total size of physical memory, in bytes.
- ullAvailPhys
- Size of physical memory available, in bytes.
- ullTotalPageFile
- Size of the committed memory limit, in bytes. This is physical memory plus the size of the page file, minus a small overhead.
- ullAvailPageFile
- Size of available memory to commit, in bytes. The limit is ullTotalPageFile.
- ullTotalVirtual
- Total size of the user mode portion of the virtual address space of the calling process, in bytes.
- ullAvailVirtual
- Size of unreserved and uncommitted memory in the user mode portion of the virtual address space of the calling process, in bytes.
- ullAvailExtendedVirtual
- Size of unreserved and uncommitted memory in the extended portion of the virtual address space of the calling process, in bytes.
Remarks
MEMORYSTATUSEX reflects the state of memory at the time of the call. It reflects the size of the paging file at that time. The operating system can enlarge the paging file up to the maximum size set by the administrator.
Jim Dempsey
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Perhaps you are not aware that we provide a sample of calling the MemoryStatus routines. In a sample, unsurprisingly, called MemoryStatus in the Win32 collection. I have not found this to be very helpful in predicting how much memory one can allocate, though it certainly can put an upper limit on it.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Could you be more specific, please?
Also, I expect that you're using a Windows OS and if Yesyou can do a very simple thing:
In System Properties set anInitial Size of Virtual Memory to 2,048 MB and Maximum Size to 4,096 MB. You could be asked to reboot your computer.
Remember, that on Win32 platforms your application will be able to allocate up to 2 GB of memory.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
bool SuggestYouStopAllocating()
{
MEMORYSTATUSEX ms;
if(!GlobalMemoryStatusEx(&ms))
return false; // ?? function call error ??
return(ms.ullTotalVirtual > (ms.ullTotalPhys / 2)); // stop at 1/2 load
// return(ms.ullTotalVirtual > ((ms.ullTotalPhys / 2)+(ms.ullTotalPhys / 4))); // stop at3/4 load
}
Adjust the threshold condition. The above uses 50% or 75%
Jim Dempsey
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
>>...
>>bool SuggestYouStopAllocating()
>>...
It's an impressive name! :)
I remember even amore impressivenaming in a C source fileone of the firstWindows SDK from Microsoft( it was still for Win16! ). It looked somethinglike this:
< some function >
{
...
if( ... )
goto CantBelieveThatIUsedGoTo;
...
CantBelieveThatIUsedGoTo:
...
}
Best regards,
Sergey
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
BTW The GOTO is not dead. Use sparingly, and only when needed.
Jim Dempsey
