GtkText Widget Memory Management
- From: "Dugas, Alan" <alan dugas analog com>
- To: gtk-list gnome org, gtk-app-devel-list gnome org
- Subject: GtkText Widget Memory Management
- Date: Fri, 30 Jun 2000 14:12:18 -0400
Hello all,
I'm am currently writing an application which monitors and displays
changes to a file. This file can get quite large and so I am attempting to
limit how much of it my application displays to some value (say 64K). Before I
did this the application would bog down to a crawl after it had gobbled up too
much RAM. However, with the simple code below inserted, I get segmentation
faults! I am somewhat suspicous if GtkText has a memory leak in it, as this
code works fine, but only for <500 iterations. Immediately prior to this it
apparently loses it mind and begins to write new text on top of old text instead
of appending it! Does anybody have any idea(s) as to what may be going on? Any
and all responses would be appreciated.
-- Stupid Genius
/* limiting gtktext widget to 64K bytes memory */
gtktext_memory_limit = pow(2,16);
gtktext_current_memory_usage = gtk_text_get_length(GTK_TEXT(text));
if ( gtktext_current_memory_usage > gtktext_memory_limit )
{
delete_length = gtktext_current_memory_usage - gtktext_memory_limit;
while ( GTK_TEXT_INDEX(GTK_TEXT(text), delete_length++) != '\n' );
gtk_text_set_point(GTK_TEXT(text), 0);
gtk_text_forward_delete(GTK_TEXT(text),
gtk_text_get_length(GTK_TEXT(text)));
gtk_text_set_point(GTK_TEXT(text), gtk_text_get_length(GTK_TEXT(text)));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]