You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
3.6 KiB

# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# T2 SDE: package/.../embutils/free.patch
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- T2-COPYRIGHT-NOTE-END ---
A memory foodprint overview can be quite handy.
Rene Rebe <rene@exactcode.de>
--- embutils-0.17/Makefile 2005-01-31 19:06:38.000000000 +0100
+++ embutils-0.17-free/Makefile 2005-02-07 01:38:31.322742920 +0100
@@ -13,7 +13,7 @@
install sosrm soscp sosmv sosln soslns md5sum sleep2 allinone kill uniq \
dd tr mesg write touch du tail uuencode uudecode nohup nice cmp mktemp \
truncate strings test date mount printenv umount pivot_root insmod rmmod \
-lsmod
+lsmod free
ARCH:=$(shell uname -m | sed 's/i[4-9]86/i386/')
--- /dev/null 2005-02-03 08:15:19.790903464 +0100
+++ embutils-0.17-free/free.c 2005-02-07 01:35:28.941469088 +0100
@@ -0,0 +1,90 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/vfs.h>
+#include <stdlib.h>
+
+/* Rene Rebe <rene@exactcode.de>
+
+/* TODO: maybe support some options ... */
+
+#include "fmt_str.c"
+#include "fmt_ulong.c"
+#include "fmt_ulongpadright.c"
+
+int main(int argc, char* argv[]) {
+ int fd=open("/proc/meminfo",O_RDONLY);
+ char buf[4096];
+ int len=read(fd,buf,4096);
+ char *line, *max;
+
+ struct meminfo_t {
+ const char* tag;
+ int val;} meminfo [] = {
+ "MemTotal", 0,
+ "MemFree", 0,
+ "Buffers", 0,
+ "Cached", 0,
+ "SwapTotal", 0,
+ "SwapFree", 0,
+ 0, 0};
+
+ line = buf;
+ max = buf + len;
+ while (line < max)
+ {
+ struct meminfo_t* i = &meminfo[0];
+ char* tmp2 = strchr(line, ' ');
+ *(--tmp2) = 0;
+
+ for (;i->tag; i++) {
+ if ( strcmp(line, i->tag) == 0 ) {
+ tmp2++; while (*tmp2 == ' ') tmp2++;
+ line = tmp2;
+ tmp2 = strchr(tmp2, '\n');
+ *tmp2 = 0;
+ i->val = atol(line);
+ line = tmp2 + 1;
+ break;
+ }
+ }
+ if (i->tag == 0)
+ line = strchr(tmp2 + 1, '\n') + 1;
+ }
+
+ len = 0;
+ len+=fmt_str (buf+len," total used free shared buffers cached\n");
+
+ len+=fmt_str (buf+len, "Mem: ");
+ len+=fmt_ulongpadright(buf+len,meminfo[0].val,10);
+ buf[len]=' '; ++len;
+ len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val,10);
+ buf[len]=' '; ++len;
+ len+=fmt_ulongpadright(buf+len,meminfo[1].val,10);
+ buf[len]=' '; ++len;
+ len+=fmt_ulongpadright(buf+len,0,10);
+ buf[len]=' '; ++len;
+ len+=fmt_ulongpadright(buf+len,meminfo[2].val,10);
+ buf[len]=' '; ++len;
+ len+=fmt_ulongpadright(buf+len,meminfo[3].val,10);
+ buf[len]='\n'; ++len;
+
+ len += fmt_str (buf+len, "-/+ buffers/cache: ");
+ {
+ int bc = meminfo[2].val + meminfo[3].val;
+ len+=fmt_ulongpadright(buf+len,meminfo[0].val - meminfo[1].val - bc,10);
+ buf[len]=' '; ++len;
+ len+=fmt_ulongpadright(buf+len,meminfo[2].val + bc,10);
+ buf[len]='\n'; ++len;
+ }
+
+ len+=fmt_str (buf+len, "Swap: ");
+ len+=fmt_ulongpadright(buf+len,meminfo[4].val,10);
+ buf[len]=' '; ++len;
+ len+=fmt_ulongpadright(buf+len,meminfo[4].val - meminfo[5].val,10);
+ buf[len]=' '; ++len;
+ len+=fmt_ulongpadright(buf+len,meminfo[5].val,10);
+ buf[len] = 0;
+ puts(buf);
+
+ return 0;
+}