| View previous topic :: View next topic |
| Author |
Message |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Sun Jan 09, 2005 4:45 pm Post subject: How to get amount of RAM? |
|
|
| I need to know how to get the amount of RAM (Physical Memory) a PC has with VDS 5. @sysinfo() only has a FreeMem option. I need TotalMem. |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sun Jan 09, 2005 6:20 pm Post subject: |
|
|
Try this...
| Code: | loadlib kernel32
%V = @binary(dword,32)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)
%A = @lib(kernel32,GlobalMemoryStatus,NIL:,@addr("%V"))
freelib kernel32
%%TotalMem = @div(@div(@val(@substr(%V,9,12)),1024),1024) |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sun Jan 09, 2005 6:38 pm Post subject: |
|
|
If you need more memory information, here's the rest of that API:
| Code: | LOADLIB KERNEL32.DLL
%V = @binary(dword,32)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)
%I = @LIB(kernel32,GlobalMemoryStatus,NIL:,@addr("%V"))
%%dwLength = @val(@substr(%V,1,4))
REM MEMORY LOAD
%%dwMemoryLoad = @val(@substr(%V,5, )
REM TOTAL PHYSICAL MEMORY
%%dwTotalPhys = @val(@substr(%V,9,12))
REM AVAILABLE PHYSICAL MEMORY
%%dwAvailPhys = @val(@substr(%V,13,16))
REM TOTAL PAGE FILE
%%dwTotalPageFile = @val(@substr(%V,17,20))
REM AVAILABLE PAGE FILE
%%dwAvailPageFile = @val(@substr(%V,21,24))
REM TOTAL VIRTUAL
%%dwTotalVirtual = @val(@substr(%V,25,2 )
REM AVAILABLE VIRTUAL
%%dwAvailVirtual = @val(@substr(%V,29,32))
FREELIB KERNEL32.DLL
|
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Jan 10, 2005 3:39 am Post subject: |
|
|
This is perfect guys.
Thanks  |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Mon Jan 10, 2005 5:56 pm Post subject: |
|
|
On a related topic, does anyone know a way to get the memory used by a particular process? I have a problem with a program that might be due to a memory leak, and I'd like to be able to plot its memory usage over time. Unfortunately I'm way too busy working on VDS 6 and other stuff to look in to how to do it. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Mon Jan 10, 2005 7:39 pm Post subject: |
|
|
I tried to figure that out, but was not able to at the time. Not sure if
anyone else has yet. But would be excellent if anyone did. I've been
wanting this ability for a long time also.
-Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Mon Jan 10, 2005 7:43 pm Post subject: |
|
|
Jules,
If you have W2k or WXP, you can run perfmon.exe.
Once you open it, select add. That will open a Add Counter dialog. From there pull down performance object, and select Process. Select your process on the right, and the specific aspect of the process you want to monitor on the left.
I hope this helps...
Hooligan
P.S. There have been entire books devoted to this program... _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Jan 11, 2005 12:12 am Post subject: |
|
|
My DiskNMem.DLL has a ProcessMem function which may be of help.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
jrmarquart Valued Newbie
Joined: 12 Jun 2004 Posts: 28 Location: Boise, ID
|
Posted: Tue Jan 11, 2005 3:18 am Post subject: Memory Leaks |
|
|
I'm a sysadmin and live and die by the utilities provided by www.sysinternals.com and www.winternals.com. For memory leaks I would recommend using a utility like pslist.
Also be sure to check out the utilities Process Explorer and Filemon - I use them all the time at work.
Download Link:
http://www.sysinternals.com/ntw2k/freeware/pslist.shtml
These are all free which is really great!
Note: Moderators - some of the information below was pulled from an article on the winnetmag.com website - please remove this post if you deem it inappropriate. If this is the case I will post a link to the article from this message.
| Quote: | Here is some info. regarding monitoring memory leaks:
If you run PsList without modifying options, it dumps a list of the processes running on a system with statistics for each process. The information is, from left to right, the process ID, priority class, number of threads, number of handles, private virtual memory allocated, amount of CPU time consumed, and time running. Excessive handle counts, high private virtual memory usage, and high CPU times can flag buggy applications. The time that a process started can connect the process with the action that started it, such as logging on.
Three switches (-m, -d, and -x) cause PsList to dump different types of process information. Use the -m switch if you want details about virtual and physical memory behavior. The data PsList presents includes the total virtual memory (shared and private) consumed by the process, the amount of physical memory assigned to the process, the private virtual memory allocated by the process, the peak amount of private memory allocated, the number of page faults, and the nonpaged and paged pool allocated by the process.
Processes that leak memory almost always do so by consuming and not releasing private virtual memory, a resource that the paging file must back and that is therefore finite. Leakers typically have ever -increasing private virtual memory allocation, and their peak amount of private memory allocated is a value that's always nearly the same as the current allocation. Task Manager's default memory number is the process's physical memory consumption (not virtual memory consumption), which isn't the correct indicator for a memory leak.
The -d switch shows details about the threads running within processes, including the context switches performed by the thread, the state of the thread (e.g., running, waiting), and the amount of CPU time consumed by the thread. Finally, the -x switch dumps process, memory, and thread detail.
Another switch that can prove useful is the -t switch, which causes PsList to dump the list of processes in process-tree format. A process tree is the structure that's built as processes create other processes; processes directly beneath another process and indented a few spaces to the right are descendants of the other process. Seeing processes in process-tree format can help you understand a process's purpose. For example, all processes that are children of SERVICES (i.e., the Service Control Manager) host Windows services.
Dumping a static view of all the processes on a system can be useful for auditing purposes or just to get an idea of what a machine is doing; however, a dynamic view of activity is usually more enlightening. When you use the -s switch, PsList updates displayed information at a default rate of once per second; you can use the -r switch to change the refresh rate. When you use only -s or only -s and -r with no additional options, PsList lists the active processes sorted by CPU usage, which effectively makes PsList a lightweight, remote Task Manager tool. PsList calculates CPU usage by comparing two updates, so the CPU usage column isn't updated until the first refresh interval expires. To exit PsList and return to a command prompt, press the Esc key.
The default view when using -s or -s and -r is useful for tracking down CPU hogs, but if you suspect a process is leaking memory, use -s in conjunction with the -m switch. This combination results in process memory statistics in which the processes are sorted by the amount of private virtual memory they've allocated. Apps leaking memory will show a process that has a private virtual memory value that has grown over time and now equals the peak private virtual memory value.
If instead of monitoring process activity, you want a process listing that reflects CPU usage, you should follow the -s switch with 2, which indicates the number of seconds PsList should run before exiting:
pslist \\remote s 2 |
Two seconds gives PsList enough time to calculate CPU usage. If you send the output to a file for archiving, you'll see two process snapshots in the file; the second snapshot shows the process list sorted by CPU usage. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|