| | |
Amount of virtual memory available?
![]() |
•
•
Join Date: Dec 2006
Posts: 9
Reputation:
Solved Threads: 0
Hi all,
I am new to windows programming. I am currently using Delphi. Is there a way to tell how much total memory (including virtual memory) is currently available on a computer.
As far as I am aware... Delphi programs start out automatically with an address space of 1 or 2 megs but more memory is automatically made available as needed by the program up until the point where the computer runs out of virtual memory.
So basically the question is...
Is there a delphi function or a win32 function that returns the amount of virtual memory that is currently available.
Any ideas?
Thanks
Eddie
I am new to windows programming. I am currently using Delphi. Is there a way to tell how much total memory (including virtual memory) is currently available on a computer.
As far as I am aware... Delphi programs start out automatically with an address space of 1 or 2 megs but more memory is automatically made available as needed by the program up until the point where the computer runs out of virtual memory.
So basically the question is...
Is there a delphi function or a win32 function that returns the amount of virtual memory that is currently available.
Any ideas?
Thanks
Eddie
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Dec 2006
Posts: 9
Reputation:
Solved Threads: 0
Ancient Dragon, thank you so much for your response. I'll have to go away and read up about the function and the SYSTEM_INFO structure that it uses.
I'll confess that at this point, I don't know how to turn the results from a populated SYSTEM_INFO structure into the data I am looking for (i.e. is it related to the page size or the minimum and maximum application addresses. I'll see if I can figure it out. Thank you so much for pointing me in the right direction. If you could be even a bit more explicit as to how to use the SYSTEM_INFO to get an Integer or Long (or Int64 or whatever) that reflects how much virtual memory can still be assigned to running programs, I would definitely appreciate the extra help. In the mean time... I'll try and figure it out.
Thanks once again.
Eddie
I'll confess that at this point, I don't know how to turn the results from a populated SYSTEM_INFO structure into the data I am looking for (i.e. is it related to the page size or the minimum and maximum application addresses. I'll see if I can figure it out. Thank you so much for pointing me in the right direction. If you could be even a bit more explicit as to how to use the SYSTEM_INFO to get an Integer or Long (or Int64 or whatever) that reflects how much virtual memory can still be assigned to running programs, I would definitely appreciate the extra help. In the mean time... I'll try and figure it out.
Thanks once again.
Eddie
•
•
Join Date: Dec 2006
Posts: 171
Reputation:
Solved Threads: 16
To retrieve the current memory status, you can use the GlobalMemoryStatus() function. The TMemoryStatus contains several fields indicating the status of the memory: .dwMemoryLoad: Total memory used in percentage (%)
. .dwTotalPhys: Total physical memory in bytes.
.dwAvailPhys: Physical memory left in bytes.
.dwTotalPageFile: Total page file in bytes.
.dwAvailPageFile
age file left in bytes.
.dwTotalVirtual: Total virtual memory in bytes.
.dwAvailVirtual: Virtual memory left in bytes.
Before presenting the memory values, convert them into giga, mega or kilobytes.
and using systeminfo
try to understand this and i'm suggesting you to start reading about API and WinApi.
best regards,
. .dwTotalPhys: Total physical memory in bytes.
.dwAvailPhys: Physical memory left in bytes.
.dwTotalPageFile: Total page file in bytes.
.dwAvailPageFile
age file left in bytes..dwTotalVirtual: Total virtual memory in bytes.
.dwAvailVirtual: Virtual memory left in bytes.
Before presenting the memory values, convert them into giga, mega or kilobytes.
Pascal and Delphi Syntax (Toggle Plain Text)
var Status : TMemoryStatus; begin Status.dwLength := sizeof( TMemoryStatus ) ; GlobalMemoryStatus( Status ) ;
and using systeminfo
Pascal and Delphi Syntax (Toggle Plain Text)
procedure TForm1.Button1Click(Sender: TObject) ; var MemoryStatus: TMemoryStatus; begin Memo1.Lines.Clear; MemoryStatus.dwLength := SizeOf(MemoryStatus) ; GlobalMemoryStatus(MemoryStatus) ; with MemoryStatus do begin Memo1.Lines.Add(IntToStr(dwLength) + ' Size of ''MemoryStatus'' record') ; Memo1.Lines.Add(IntToStr(dwMemoryLoad) + '% memory in use') ; Memo1.Lines.Add(IntToStr(dwTotalPhys) + ' Total Physical Memory in bytes') ; Memo1.Lines.Add(IntToStr(dwAvailPhys) + ' Available Physical Memory in bytes') ; Memo1.Lines.Add(IntToStr(dwTotalPageFile) + ' Total Bytes of Paging File') ; Memo1.Lines.Add(IntToStr(dwAvailPageFile) + ' Available bytes in paging file') ; Memo1.Lines.Add(IntToStr(dwTotalVirtual) + ' User Bytes of Address space') ; Memo1.Lines.Add(IntToStr(dwAvailVirtual) + ' Available User bytes of address space') ; end; end;
try to understand this and i'm suggesting you to start reading about API and WinApi.
best regards,
•
•
Join Date: Dec 2006
Posts: 9
Reputation:
Solved Threads: 0
I just wanted to say a quick thank you for the replies to this thread. I really appreciate them. Radu84, I haven't even had a chance to read your post at this point. The reason for this is that I just received word this morning that there has been a death in my immediate family. I will be travelling abroad and don't expect to have internet access for about a week.
I'll take up the work I was trying to do when I get back early in January. I just wanted to let you guys know... that my lack of response wasn't due to any unappreciation of your help. I appreciate the time and effort you have given in helping me with my question.
Therefore... please know that any lack of further responses from me for just over a week is due to know lack in appreciation.
Sincerely.
Eddie
I'll take up the work I was trying to do when I get back early in January. I just wanted to let you guys know... that my lack of response wasn't due to any unappreciation of your help. I appreciate the time and effort you have given in helping me with my question.
Therefore... please know that any lack of further responses from me for just over a week is due to know lack in appreciation.
Sincerely.
Eddie
•
•
Join Date: Dec 2006
Posts: 9
Reputation:
Solved Threads: 0
Hi guys,
I'm now back from being with the family. Radu84, I've now had a chance to read your post. The 'dwAvailVirtual' field of the TMemoryStatus object/structure sounds like EXACTLY what I want. I'll go and try it out.
Thanks Acient Dragon and Radu84 for your responses.
Best wishes and Happy New Year.
Eddie
I'm now back from being with the family. Radu84, I've now had a chance to read your post. The 'dwAvailVirtual' field of the TMemoryStatus object/structure sounds like EXACTLY what I want. I'll go and try it out.
Thanks Acient Dragon and Radu84 for your responses.
Best wishes and Happy New Year.
Eddie
![]() |
Similar Threads
- Virtual Memory Won't Stay Put Even When I Click Set (Windows NT / 2000 / XP)
- Setting a static page file (virtual memory) (Windows tips 'n' tweaks)
- System running very slow: virtual memory (Viruses, Spyware and other Nasties)
- “Windows Virtual Memory Size Too Low� in XP (Windows NT / 2000 / XP)
- Virtual Memory - Better on Seperate Disk? (Windows NT / 2000 / XP)
- win2k low on virtual memory... (Windows NT / 2000 / XP)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: The question of Pascal random command ????
- Next Thread: validate days in a month
| Thread Tools | Search this Thread |






