Hi,
There are two questions:
1, How to get the available physical memory in solaris 2.7 system? I know I
can get the totle physical memory with the c function sysconf, but how can I
get the available physical memory with C code.
2, How to get hard disk with c code just like the command df -k . in the
solaris 2.7 system?
Thanks,
Ben
|
|
0
|
|
|
|
Reply
|
Benjamin
|
12/10/2003 8:51:16 AM |
|
Benjamin Wang wrote :
> There are two questions:
> 1, How to get the available physical memory in solaris 2.7 system? I know I
> can get the totle physical memory with the c function sysconf, but how can I
> get the available physical memory with C code.
and why won't you use the C function sysconf() ?
--
DINH V. Hoa,
etPan! - newsreader, mail user agent -- http://libetpan.sf.net/etpan
|
|
0
|
|
|
|
Reply
|
DINH
|
12/10/2003 10:17:31 AM
|
|
See http://docs.sun.com/db/doc/816-0213/6m6ne38dd?a=view
You can call sysconf() an get the same information as the OS sysconf
Benjamin Wang wrote:
> Hi,
>
> There are two questions:
> 1, How to get the available physical memory in solaris 2.7 system? I know I
> can get the totle physical memory with the c function sysconf, but how can I
> get the available physical memory with C code.
>
> 2, How to get hard disk with c code just like the command df -k . in the
> solaris 2.7 system?
>
>
> Thanks,
> Ben
>
>
|
|
0
|
|
|
|
Reply
|
Joseph
|
12/10/2003 3:55:39 PM
|
|
"Benjamin Wang" <zwang2@lucent.com> wrote in message
news:br6mqf$qmk@netnews.proxy.lucent.com...
> 1, How to get the available physical memory in solaris 2.7 system? I know
I
> can get the totle physical memory with the c function sysconf, but how can
I
> get the available physical memory with C code.
Define what you mean by "available". Do you mean only memory that is
literally not in use? What about memory that contains clean copies of data
on disk and can be discarded immediately -- is that "available"?
> 2, How to get hard disk with c code just like the command df -k . in the
> solaris 2.7 system?
Probably 'statvfs' is what you want.
DS
|
|
0
|
|
|
|
Reply
|
David
|
12/10/2003 6:33:20 PM
|
|
Hi David,
The available physical memory means the physical memory unused.Sorry for
confused. Is there a c system call to get it?
I have tried statvfs, and worked well. But man page mentions that there are
bugs for NFS. So, for NFS, how could I get hard disk data?
Thanks,
Ben
"David Schwartz" <davids@webmaster.com> wrote in message
news:br7otg$jfc$1@nntp.webmaster.com...
>
> "Benjamin Wang" <zwang2@lucent.com> wrote in message
> news:br6mqf$qmk@netnews.proxy.lucent.com...
>
> > 1, How to get the available physical memory in solaris 2.7 system? I
know
> I
> > can get the totle physical memory with the c function sysconf, but how
can
> I
> > get the available physical memory with C code.
>
> Define what you mean by "available". Do you mean only memory that is
> literally not in use? What about memory that contains clean copies of data
> on disk and can be discarded immediately -- is that "available"?
>
> > 2, How to get hard disk with c code just like the command df -k . in the
> > solaris 2.7 system?
>
> Probably 'statvfs' is what you want.
>
> DS
>
>
|
|
0
|
|
|
|
Reply
|
Benjamin
|
12/11/2003 3:53:39 AM
|
|
"Benjamin Wang" <zwang2@lucent.com> wrote in message
news:br8poh$8oo@netnews.proxy.lucent.com...
> The available physical memory means the physical memory unused.Sorry for
> confused. Is there a c system call to get it?
It will be near zero on most modern UNIX machines. They use all
available memory pretty much all the time. You will find that only memory on
the shelf is unused. The OS will keep copies of disk data in memory just in
case someone wants to read them again shortly.
My home Linux machine, for example, has 512Mb of physical memory. But it
always has 19Mb free no matter how busy it is. That's because it only keeps
memory free for emergencies (like a large burst of network data) and, by
design, keeps about 3%-4% of the physical memory free. Otherwise, it's more
sensible to keep disk data in memory. In fact, right now my system has 215Mb
of memory holding copies of data read from or written to disk just in case
it's accessed again.
For all practical purposes, free memory is memory not installed in a
UNIX machine.
DS
|
|
0
|
|
|
|
Reply
|
David
|
12/11/2003 11:00:45 AM
|
|
On Wed, 10 Dec 2003 11:17:31 +0100, DINH Viet Hoa wrote:
> Benjamin Wang wrote :
>
>> There are two questions:
>> 1, How to get the available physical memory in solaris 2.7 system? I
>> know I can get the totle physical memory with the c function sysconf,
>> but how can I get the available physical memory with C code.
>
> and why won't you use the C function sysconf() ?
First, sysconf() is not a "C" function. It's an API provided by most UNIX
like operating systems. You won't find sysconf() in any C language
standard. Second, as Mr. Shwartz has pointed out on any UNIX system that
has been running for any length of time the amount of available (i.e.,
"free") memory will normally be close to zero. On my home system with
1.25GiB of physical memory sysconf(_SC_AVPHYS_PAGES) reports 1386 pages
available as I write this. But most of the "non-free" pages are actually
part of various caches which will shrink if need be. I would have no
problem starting a program which needed more than 1386 pages of memory.
The question posed by the O.P. is essentially meaningless. A more
meaningful question might be "what is the minimum amount of memory
required by the operating system?" Subtracting that value from the amount
of physical memory would provide an approximation of the maximum amount of
memory any one process could utilize. But even that is an
oversimplification since there are other processes running with their own
dynamic memory needs which can't be ignored if you don't want the system
to thrash.
Most people asking this question do so because they want their program to
dynamically adjust its memory use. In practice it simply isn't possible.
At least not in a straightforwad manner such as by asking for how much
"available" memory there is. The simplest approach that is practical is to
use sysconf(_SC_PHYS_PAGES) to find out how much physical memory is
present then calculate a fraction of that value. But note that in a NUMA
architecture that will probably not yield a useful value since you
wouldn't normally want a process to use "remote" memory.
|
|
0
|
|
|
|
Reply
|
Kurtis
|
12/13/2003 10:55:50 PM
|
|
|
6 Replies
303 Views
(page loaded in 0.056 seconds)
Similiar Articles: proc sql group by memory and disk usage - comp.soft-sys.sas ...Hi=2C i would like some help on the memory and disk usage ... which says ... Space available for the hard disk. ... insufficient physical memory while oracle installation ... Recommended disk layout for Solaris 10 - comp.unix.solaris ...... please forgive my popssibly dumb questions ... heard I need /var with 2 times physical memory ... to be twice of memory, but your memory is small, so 4GB is good. Your hard disk ... Where do message queues, named pipes reside? - comp.unix ...One basic question: What is the actual physical storage place for message queues and named pipes? Do they exist as part of disk or memory always, impl... Smart Array Disk Replace - comp.periphs.scsiHow to display number of physical drives in an array ... Hard Disk Utilities - comp.soft-sys.matlab How do I ... obviously won't help if one of the busses (memory, disk ... insufficient physical memory while oracle installation - comp.unix ...... Checking physical memory requirements ... wants a MINIMUM of FIVE physical disk ... size kernel parameter (hard limit) solaris 8 - comp ... insufficient physical memory ... appleworks aux ram driver - comp.sys.apple2.programmerOn an Apple II with a hard drive ... to > handle blocks swapped to disk would be fairly straightforward... the > question ... editing using only as much physical memory as ... Any way to flush to disk mem-mapped file writes? - comp.unix ...... Post Question | Groups ... Having many of such files on a hard disk there is no ... Using memory mapped files to conserve physical memory for ... How to force swapping a Smartheap memory pool to disk - comp.lang ...My question is, how to FORCE a memory pool to be swapped to disk? The purpose is, when the data in the memory ... How to increase write speed to local hard drive? - comp ... Howto connect two computer and some hard disks with fibre channel ...Fiber Cabling Questions - comp.dcom.cabling Howto connect two computer and some hard disks with fibre channel ..... Post Question | Groups ... Competition ... you will ... IOCTL_DISK_GET_PARTITION_INFO and the PartitionType field problem ...... Post Question ... tried using IOCTL_DISK_GET_DRIVE_LAYOUT on a handle for the physical ... since you target a memory stick, plug-n-play device, not a hard disk ... What's the difference between memory and hard disk space?Memory, hard disk, and RAM: I get a surprising number of questions that show a misunderstanding ... Drive (HDD), or sometimes just hard disk or hard drive, uses physical ... What is the difference between memory and hard disk space?An answer to the question: What is the difference between memory and hard disk space? ... Next Hardware Question: What is the difference between physical memory and ... 7/25/2012 4:02:42 AM
|