forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to get amount of RAM?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Sun Jan 09, 2005 4:45 pm    Post subject: How to get amount of RAM? Reply with quote

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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Jan 09, 2005 6:20 pm    Post subject: Reply with quote

Try this... Smile

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
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sun Jan 09, 2005 6:38 pm    Post subject: Reply with quote

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,Cool)
      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,2Cool)
      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
View user's profile Send private message
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Mon Jan 10, 2005 3:39 am    Post subject: Reply with quote

This is perfect guys.

Thanks Very Happy
Back to top
View user's profile Send private message Send e-mail
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Mon Jan 10, 2005 5:56 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Mon Jan 10, 2005 7:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Mon Jan 10, 2005 7:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Tue Jan 11, 2005 12:12 am    Post subject: Reply with quote

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
View user's profile Send private message
jrmarquart
Valued Newbie


Joined: 12 Jun 2004
Posts: 28
Location: Boise, ID

PostPosted: Tue Jan 11, 2005 3:18 am    Post subject: Memory Leaks Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group