Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote a simple program in c++ that does some calculations, outputs a number to a textfile, and repeats. Several million times. The final text file was around 215 megabytes, yet when I opened it, gedit took over 5 minutes to open all of it, and I went over my 4 Gb of ram and into the linux swap. Why does this happen when the original file size is only 200 MB?

share|improve this question

migrated from stackoverflow.com Mar 9 '11 at 2:44

This question came from our site for professional and enthusiast programmers.

3  
gedit is the one using up high amounts of memory, not your own program, right? – Dre Mar 9 '11 at 2:30
    
Correct. The program when executed took up under 20 Mb but slowly rose by about .1 Mb every minute. – a sandwhich Mar 9 '11 at 2:31
    
Run gedit from valgrind. This will tell you wether there are memory leaks present in your version of gedit. On my system (Ubuntu 12.04.4) this is the case. So I have to quit all instances of gedit from time to time to free all the memory. – Dohn Joe Mar 1 '14 at 15:30
up vote 4 down vote accepted

Searching around on Google, gedit seems to handle large files very badly

I would try opening the files in something like less

vim by default does not behave as well as I thought it did on large files, if you want to use vim you should use something like http://www.vim.org/scripts/script.php?script_id=1506

share|improve this answer
    
Well, I just tried opening the file in gvim, and the ram usage only increased by about 230 MB. It is funny, I opened a program written in c a while ago that was about 100 mb, but gedit didn't react so severly. Thanks. – a sandwhich Mar 9 '11 at 2:42
    
And to answer the other part of your question, I really do not know why gedit uses that much memory -- may be partly due to bad programming, or a bug. I don't see any reason why it should. If you want the least memory intensive way to view a huge file, I think less is the only way to go, from my digging ( you can't edit it in that case, though ) – Dre Mar 9 '11 at 2:45
    
+1 for less! I once had to open a 37.1 GiB file and only less worked! – AndrejaKo Mar 9 '11 at 2:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .