Getting free physical Memory ?
-
-
Hello, I would like to know if it's possible (and how) to get the free memory (RAM). I searched in google and here on the forum but had no luck so far. (It's also quit difficult to search for "free memory" ) Thanks for youre time and help, Martin
That's hardware, and hardware isnt downloadable:laugh:
:badger:
-
Hello, I would like to know if it's possible (and how) to get the free memory (RAM). I searched in google and here on the forum but had no luck so far. (It's also quit difficult to search for "free memory" ) Thanks for youre time and help, Martin
Yes, I guess it's possible using SDK Memory related API's. Can't recall the exact API's though (had used them some 5yrs back :doh:), try finding them on MSDN. Hummm .... can recall of one called "GetSystemInfo" which returns info about current system. Good luck !! Regards, Bhupi Bhai.
-
That's hardware, and hardware isnt downloadable:laugh:
:badger:
-
Hello,
Anton Afanasyev wrote:
That's hardware, and hardware isnt downloadable
:confused: Sorry but I don't even understand that joke? Maybe you can help next time.
gaaaah whats with people and no sense of humour. hmm, maybe its due to me having to be in bed by now... anyways, what i mean was that you were asking where you could get free RAM, and searching in google didnt help. as in, nobody willing to give you free ram. /me holds up "LAUGH NOW" sign...
:badger:
-
Yes, I guess it's possible using SDK Memory related API's. Can't recall the exact API's though (had used them some 5yrs back :doh:), try finding them on MSDN. Hummm .... can recall of one called "GetSystemInfo" which returns info about current system. Good luck !! Regards, Bhupi Bhai.
-
gaaaah whats with people and no sense of humour. hmm, maybe its due to me having to be in bed by now... anyways, what i mean was that you were asking where you could get free RAM, and searching in google didnt help. as in, nobody willing to give you free ram. /me holds up "LAUGH NOW" sign...
:badger:
-
Yes, I guess it's possible using SDK Memory related API's. Can't recall the exact API's though (had used them some 5yrs back :doh:), try finding them on MSDN. Hummm .... can recall of one called "GetSystemInfo" which returns info about current system. Good luck !! Regards, Bhupi Bhai.
Hello, Had no luck with that. GetSystemInfo returns a:
\[StructLayout(LayoutKind.Sequential)\] class SYSTEM\_INFO { public ushort wProcessorArchitecture; public ushort wReserved; public uint dwPageSize; public IntPtr lpMinimumApplicationAddress; public IntPtr lpMaximumApplicationAddress; public IntPtr dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public ushort wProcessorLevel; public ushort wProcessorRevision; }
I implemented it like that:
\[DllImport("kernel32.dll", CharSet = CharSet.Unicode,CallingConvention = CallingConvention.Winapi, EntryPoint = "GetSystemInfo")\] private static extern void GetSystemInfo(\[In,MarshalAs(UnmanagedType.LPStruct)\]SYSTEM\_INFO pSysInfo);
And called it like that:
SYSTEM\_INFO sysinfo = new SYSTEM\_INFO(); GetSystemInfo(sysinfo);
But I didn't found a member that fits me needs:~ If I made something wrong, please let me know. But again thanks for youre time. Martin
-
Hello, Had no luck with that. GetSystemInfo returns a:
\[StructLayout(LayoutKind.Sequential)\] class SYSTEM\_INFO { public ushort wProcessorArchitecture; public ushort wReserved; public uint dwPageSize; public IntPtr lpMinimumApplicationAddress; public IntPtr lpMaximumApplicationAddress; public IntPtr dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public ushort wProcessorLevel; public ushort wProcessorRevision; }
I implemented it like that:
\[DllImport("kernel32.dll", CharSet = CharSet.Unicode,CallingConvention = CallingConvention.Winapi, EntryPoint = "GetSystemInfo")\] private static extern void GetSystemInfo(\[In,MarshalAs(UnmanagedType.LPStruct)\]SYSTEM\_INFO pSysInfo);
And called it like that:
SYSTEM\_INFO sysinfo = new SYSTEM\_INFO(); GetSystemInfo(sysinfo);
But I didn't found a member that fits me needs:~ If I made something wrong, please let me know. But again thanks for youre time. Martin
Yes, ur on the right track. But I am sorry can't recall the exact API for it. You will have to do some more rnd on this. Regards, Bhupi Bhai.
-
Hello, I would like to know if it's possible (and how) to get the free memory (RAM). I searched in google and here on the forum but had no luck so far. (It's also quit difficult to search for "free memory" ) Thanks for youre time and help, Martin
I would suspect you can get the info though WMI. Using WMI from C# is fairly simple - you should be able to get a sample from Google. I would probably try to split the search into two: 1) How to use WMI from C# 2) How to get the free memory though WMI (in any language) just in case you can't easily find an example getting the free memory from C#.
-
I would suspect you can get the info though WMI. Using WMI from C# is fairly simple - you should be able to get a sample from Google. I would probably try to split the search into two: 1) How to use WMI from C# 2) How to get the free memory though WMI (in any language) just in case you can't easily find an example getting the free memory from C#.
-
Hello, I would like to know if it's possible (and how) to get the free memory (RAM). I searched in google and here on the forum but had no luck so far. (It's also quit difficult to search for "free memory" ) Thanks for youre time and help, Martin
Got it now!:-> Here is what I'm using now:
\[StructLayout(LayoutKind.Sequential)\] class MEMORYSTATUS { public IntPtr dwLength; public IntPtr dwMemoryLoad; public IntPtr dwTotalPhys; public IntPtr dwAvailPhys; public IntPtr dwTotalPageFile; public IntPtr dwAvailPageFile; public IntPtr dwTotalVirtual; public IntPtr dwAvailVirtual; } \[DllImport("kernel32.dll", CharSet = CharSet.Unicode,CallingConvention = CallingConvention.Winapi, EntryPoint = "GlobalMemoryStatus")\] private static extern void GlobalMemoryStatus(\[In,MarshalAs(UnmanagedType.LPStruct)\]MEMORYSTATUS lpBuffer);
Maybe somebody needs it. Thanks for the replies. All the best, Martin
-
Yes, ur on the right track. But I am sorry can't recall the exact API for it. You will have to do some more rnd on this. Regards, Bhupi Bhai.
-
Hello, I think I found it 5minutes ago. But I will need it in future. Thank you. All the best, Martin
Yes, lmoelleb (is that ur name) is right. Using WMI in C# you can get Free Physical Memory. ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem"); ManagementObjectCollection queryCollection1 = query.Get(); foreach(ManagementObject mo in queryCollection1 ) { Console.WriteLine("Free Physical Memory : " + mo["freephysicalmemory"].ToString()); } Regards, Bhupi Bhai.
-
If it makes youre day better, I send you: :laugh::laugh:
Anton Afanasyev wrote:
whats with people and no sense of humour
Maybe humor like that makes more fun if it is posted togetter with a real answer! All the best, Martin
The sad thing is, I replied to what I thought he meant...then later, adapted that answer to the situation. heh.I guess I deserved those 1 votes.
:badger: