1MemInfo(3) User Contributed Perl Documentation MemInfo(3)
2
3
4
6 Sys::MemInfo - query the total free and used physical memory
7
9 use Sys::MemInfo qw(totalmem freemem totalswap);
10
11 print "total memory: ".(&totalmem / 1024)."\n";
12 print "free memory: ".(&freemem / 1024)."\n";
13
14 print "total swap: ".(&totalswap / 1024)."\n";
15 print "free swap: ".(Sys::MemInfo::get("freeswap") / 1024)."\n";
16
18 Sys::MemInfo return the total amount of free and used physical memory
19 in bytes in totalmem and freemem variables.
20
21 Total amount of free and user swap memory are alse returned in
22 totalswap and freeswap variables.
23
24 This module has been tested on Linux 3.13.0, UnixWare 7.1.2, AIX5,
25 OpenBSD 3.8, NetBSD 2.0.2, FreBSD 5.4, HPUX11, Solaris 9, Tru64 5.1,
26 Irix 6.5, Mac OS X 10.2 darwin and Windows XP.
27
28 It should work on FreeBSD 4 and Windows 9X/ME/NT/200X/Vista.
29
31 availkeys
32 Return list of all accessor keys (freemem, totalmem, etc.) This is
33 useful for dumping out all known information from the object by
34 calling get() on all of the returned keys.
35
36 freemem
37 Returns free physical memory in bytes.
38
39 freeswap
40 Returns free swap space in bytes.
41
42 get Returns the value of the passed key.
43
44 totalmem
45 Returns total physical memory size in bytes.
46
47 totalswap
48 Returns total swap space in bytes.
49
51 Sylvain Cresto <scresto@gmail.com>
52
53 Thanks to Laurent Dufour and Wilson Snyder.
54
56 Please send bug-reports to scresto@gmail.com
57
59 This library is free software; you can redistribute it and/or modify it
60 under the same terms as Perl itself.
61
63 Copyright (C) 2005, 2006, 2014, 2016 - Sylvain Cresto
64
65
66
67perl v5.36.0 2023-01-20 MemInfo(3)