views:

258

answers:

2

Hi all,

I was initially dabbling with IFrames to launch a document, and found that for large files, the memory in all browsers (I first noticed this in FF) jumped to 500,000 K.

At first I thought it might have been some bad JS code that I had written, but removing all the extraneous code and just OPENING the text file still displayed the same problem.

So right now, all I'm doing is going to a site http://url/largefile, and seeing the file slowly display to the screen.

Is there any efficient way for me to display the file without the browser exploding? What am I missing here?

Thanks,
Michael

EDIT: I've received responses to use a text editor for this purpose. My original goal was to allow a user to click the url, which would append a search term as a post variable. The opened textfile would then scroll to the specified point of the search term. Is there a way to auto open a text editor ... on that person's computer and then going directly to the search point?

A: 

Is it xml? Firefox tries to create a DOM for xml files that can be many times larger than the file itself.

Joel Coehoorn
It's not xml, there's no specified format; it's just text, however, could this also be the case here?
Michael
Yes. Firefox will internally convert text files to HTML for rendering. You can see this yourself by using firebug - try using a popup dictionary tool (eg, rikaichan) on a .txt file while looking at the firebug DOM view.
bdonlan
+3  A: 

30MB is kind of big, even for a regular text editor, I suspect you will be unable to convince FF to handle it well. I might try one of the following:

  1. implement paging/searching in your web site so it only displays a portion of the file at one time
  2. open the file in an actual text editor - it's what they are good at after all

Your paging implementation (if suitably clever) might only load the text around the selected piece of the file, and when they scroll up or down use AJAX to load additional parts of the file (kind of like a virtual list control in windows). This might help to mitigate the performance impact.

1800 INFORMATION
Also, some text editors are better at handling large files than others. If the first one you try seems sluggish, try another.
Amber
Michael
I added some more details about how you might like to try implementing some smart pagine functionality. I don't know if it's really possible to do, or how much work you want to put into it. The main point is not to try to load the whole file into memory at once.
1800 INFORMATION
Ok, I'll probably just take your answer for future reference; as of now I do not have the time to implement such a mechanism, thought that sounds pretty neat.
Michael