Memory usage


I have writen (or copied) a simple example for a gtk trayicon.

Looking it with gnome-system-monitor it shows
20.4Mb of virtual Memory.
5.9Mb   of resident memory.
1.6 Mb of "writable memory"
4.4 Mb of writable memory.
1.7 Mb in the Memory Column

The compiled size is only 8 kbytes.

How can i really know how much memory is my program using, i think
that it should be just a few kb plus the size of some gtk variables
and never 1.6 Mb since the gtk libs are shared.

The code is as follows and is copied from a blog somewhere finding with google.

/* simple.c */
// Compile with:
// gcc `pkg-config --cflags --libs gtk+-2.0 glib-2.0 gthread-2.0`
simple.c -o simple

#include <gtk/gtk.h>

void tray_icon_on_click(GtkStatusIcon *status_icon, gpointer user_data)
  printf("Clicked on tray icon\n");

void tray_icon_on_menu(GtkStatusIcon *status_icon, guint button, guint
activate_time, gpointer user_data)
  printf("Popup menu\n");

static GtkStatusIcon *create_tray_icon() {
  GtkStatusIcon *tray_icon;

  tray_icon = gtk_status_icon_new();
  g_signal_connect(G_OBJECT(tray_icon), "activate",
G_CALLBACK(tray_icon_on_click), NULL);
  g_signal_connect(G_OBJECT(tray_icon), "popup-menu",
G_CALLBACK(tray_icon_on_menu), NULL);
  gtk_status_icon_set_from_icon_name(tray_icon, GTK_STOCK_MEDIA_STOP);
  gtk_status_icon_set_tooltip(tray_icon,"Example Tray Icon");
  gtk_status_icon_set_visible(tray_icon, TRUE);

  return tray_icon;

int main(int argc, char **argv) {
  GtkStatusIcon *tray_icon;

  gtk_init(&argc, &argv);
  tray_icon = create_tray_icon();

  return 0;

Thanks in advance.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]