Adobe AIR。本地网络错误
例如,在本地网络中,当 Adobe Air 从本地服务器 (\\Server\storage\
) 读取文件时,网络会暂时中断,Air 会消耗大量内存,并且增加至 1GB(而正常内存使用量为 100 kb 或更少)。 仅从不稳定的网络中使用 File('本地服务器上的文件路径');
读取文件可能会导致此错误。 有人在项目中看到过吗?
private function init() : void
{
file = new File("\\Server\dragracing\results.txt");
fileStream = new FileStream();
fileStream.addEventListener( Event.COMPLETE, fileComplete );
fileStream.openAsync( file, FileMode.READ );
}
private function fileComplete( event : Event ):void
{
fileContents = fileStream.readMultiByte( fileStream.bytesAvailable, ISO_CS );
.....
}
]]>
For example, in local network, when Adobe Air is reading files from local server (\\Server\storage\
) and network will be in down for a second, Air becomes eat a lot of memory and it is increasing up to 1GB (while normal memory use is 100 kb or less).
Just reading file with File('file path on local server');
from unstable network can cause this error.
Have anybody seen that in projects?
private function init() : void
{
file = new File("\\Server\dragracing\results.txt");
fileStream = new FileStream();
fileStream.addEventListener( Event.COMPLETE, fileComplete );
fileStream.openAsync( file, FileMode.READ );
}
private function fileComplete( event : Event ):void
{
fileContents = fileStream.readMultiByte( fileStream.bytesAvailable, ISO_CS );
.....
}
]]>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过在 fileComplete 方法中关闭 FileStream ?调用关闭方法< /a> 来实现这一点。
私有函数 fileComplete( 事件 : 事件 ):void
{
fileContents = fileStream.readMultiByte( fileStream.bytesAvailable, ISO_CS );
文件流.close();
……
另外,根据您的代码
,您似乎并未真正从文件中读取信息。从文件中;因此尚不清楚完整的方法是否会执行。有很多方法可用于使用 FileStream 类。
Have you tried closing the FileStream in the fileComplete method? Call the close method to make that happen.
private function fileComplete( event : Event ):void
{
fileContents = fileStream.readMultiByte( fileStream.bytesAvailable, ISO_CS );
fileStream.close();
.....
}
Also, based on your code it does not appear that you are ever actually reading information in from the file. from the file; so it is not clear the complete method will ever execute. There are plenty of methods used to read information in using the FileStream class.