After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 127840 - gtktextview uses huge amounts of memory on large files
gtktextview uses huge amounts of memory on large files
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.2.x
Other Linux
: Normal normal
: Medium fix
Assigned To: gtk-bugs
gtk-bugs
: 679724 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-11-24 20:53 UTC by Kjartan Maraas
Modified: 2014-07-25 19:25 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kjartan Maraas 2003-11-24 20:53:16 UTC
I tried loading a 10 meg file with one *huge* line of 'A's in testtext and
gedit and watched it spend ages to load the thing. When it finished reading
the file in it spent a huge amount of time allocating memory. After a while
it was using 550 megs of RAM and still hadn't gotten to the point where I
could see the file's content.

I tried the same after adding linebreaks after every 'A' (20 meg file)
which made it read the full file faster, but it still consumed over 500
megs of ram without being able to show the file content. Tried this using
gtk-2-2 (gedit) and HEAD (testtext)
Comment 1 Matthias Clasen 2003-11-27 21:51:20 UTC
You picked the two extreme cases at which the textbuffer sucks. If you
split 10M As in lines of 128 bytes each, gedit loads the file quickly
and uses only 34M. To cite docs/text_widget_internal.txt:

The text widget is efficient for huge numbers of paragraphs, but will
choke on extremely long blocks of text without intervening newlines.

(This explains why a 10M character paragraph sucks, but not why 10M 1
character paragraphs kill the text view.)
Comment 2 Matthias Clasen 2003-11-27 22:03:53 UTC
Looking at the structures used to store lines in the B-tree, we seem
to have a GtkTextLine (16 bytes) and at least one GtkTextLineSegment
(>= 20 bytes) per line, so for your example of 10M 1 character lines,
we roughly need 36*10M bytes for the leafs of the tree. If you add the
tree itself, you may well end up with ~500M. 
Comment 3 Kjartan Maraas 2011-02-08 18:20:17 UTC
Maybe this should just be closed since the limitations are well known and documented?
Comment 4 Rubén Caro 2013-10-28 08:11:13 UTC
Will this ever be fixed? Any plans to remove these limitations?
Comment 5 Emmanuele Bassi (:ebassi) 2013-10-28 11:16:04 UTC
it's safe to say that, if nobody has worked on the (documented) limitations for the past 10 years, it's unlikely that somebody will. unless, obviously, you're volunteering.
Comment 6 Sébastien Wilmet 2013-11-04 21:12:36 UTC
*** Bug 679724 has been marked as a duplicate of this bug. ***
Comment 7 Matthias Clasen 2014-07-25 19:25:39 UTC
I'm going to close this. If somebody shows up to work on this, they can simply open a new bug to attach their patch.