打开一个大文本文件(30mb)会消耗500,000k的Firefox内存 [英] Opening a large text file (30mb) consumes 500,000k of Firefox memory

查看:158
本文介绍了打开一个大文本文件(30mb)会消耗500,000k的Firefox内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最初是在和iframe打交道发现一个文件,发现对于大文件,所有浏览器中的内存(我第一次注意到这个在FF中)跳到500,000 K。

起初我以为这可能是我编写的一些不好的JS代码,但删除所有无关的代码,只是打开文本文件仍然显示相同的问题。
$ b $现在,我所做的只是去 http:// url / largefile 网站,并看到文件缓慢地显示到屏幕上。

有没有有效的方式来显示文件,而浏览器爆炸?我在这里错过了什么?






编辑:我已收到使用文本编辑器为此目的的响应。我最初的目标是允许用户点击url,这会将搜索词作为后期变量添加。打开的文本文件将滚动到搜索项的指定点。有没有办法自动打开一个文本编辑器...在该人的计算机,然后直接进入搜索点?

解决方案

30MB是一个很大的,即使是一个普通的文本编辑器,我怀疑你将无法说服FF来处理它。我可能会尝试以下方法之一:


  1. 在您的网站中实现分页/搜索,所以它只能同时显示一部分文件

  2. 在实际的文本编辑器中打开文件 - 毕竟是他们擅长的功能

你的分页实现(如果合适的话)只能加载选定文件周围的文本,当它们向上或向下滚动时,使用AJAX加载文件的其他部分(类似于窗口中的虚拟列表控件)。这可能有助于缓解性能影响。


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?


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?

解决方案

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.

这篇关于打开一个大文本文件(30mb)会消耗500,000k的Firefox内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆