in reply to Re: Tk Win32 memory overhead
in thread Tk Win32 memory overhead

But does it just do that from perl? or does it do that from C also? That's the real question imo.

-Paul

Replies are listed 'Best First'.
Re^3: Tk Win32 memory overhead
by zentara (Cardinal) on Nov 02, 2007 at 11:49 UTC
    Its hard to test Tk against C, but with Gtk2 it can be done. Below are the same program, one in Gtk2-c and one Gtk2-perl. Here are the top output when run:
    # for c version zentara 15 0 14368 7012 5400 S 0.0 0.7 0:00 .07 . +/basic-window-c #for the Perl version zentara 18 0 21700 12m 9056 S 0.0 1.3 0:00 12 + ./basic-window.pl
    As you can see Perl uses way more memory; 12m versus 7k for c. The question becomes, with systems with 1 and 2 gigs of ram being common, can you afford the extra ram usage, in exchange for the ease of writing it in Perl? For me, the answer is yes. C can take hours, where Perl is done in minutes.
    /* compile test-c.c with gcc -o test-c test-c.c `pkg-config --cflags --libs gtk+-2.0` */ #include <gtk/gtk.h> void destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK(des +troy), 1); gtk_container_set_border_width(GTK_CONTAINER (window), 10); button = gtk_button_new_with_label ("Some Button"); gtk_container_add(GTK_CONTAINER(window), button); gtk_widget_show(button); gtk_widget_show (window); gtk_main (); return 0; }
    #!/usr/bin/perl use warnings; use strict; use Gtk2 '-init'; my $window = Gtk2::Window->new; my $button = Gtk2::Button->new('Some Button'); my $vbox = Gtk2::VBox->new(); $window->set( border_width => 15 ); $window->add($button); $window->signal_connect('destroy', sub { Gtk2->main_quit }); $window->show_all(); Gtk2->main;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum