如何清除ram在List< byte>上的工作和字节数组? [英] How to clear ram working on List<byte> and byte array?
本文介绍了如何清除ram在List< byte>上的工作和字节数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发mp3流媒体。我在这个项目中使用了Mark Heath的NAudio.dll。但流式MP3帧必须解压缩才能收听。我使用List和byte数组来存储数据。因此每次播放mp3时,ram的使用量超过200 mb。但主要问题是我的代码在播放3或4首歌后抛出OutOfMemoryException异常。我尝试了= null和Clear()方法,但似乎它不起作用。如何解决这个问题。在此先感谢。
I am working on mp3 streaming. I used Mark Heath's NAudio.dll for this project. But streamed mp3 frames must be decompressed to listen. I m using List and byte array to storage data. So that ram using is over 200 mb on every mp3 playing. But main problem is my code throw OutOfMemoryException exception after 3 or 4 song played. I tried "=null and Clear()" method but it seems it doesnt work.How can I fix this problem. Thanks in advance.
推荐答案
堆栈溢出与列表的大小或任何描述的数组无关 - 在C#中,这些始终是引用类型,因此存储在堆上,而不是堆栈。
所以看看你的代码:堆栈溢出异常的最可能原因是你有一些无意的递归吃你的堆栈而不是直接与您存储数据的结构有关。
Stack overflow has nothing to do with the size of Lists, or arrays of any description - in C# these are always Reference types, and as such are stored on the Heap, not the stack.
So look at your code: the most likely reason for a Stack Overflow Exception is that you have some inadvertent recursion eating your stack rather than anything directly to do with the structures you are storing data in.
这篇关于如何清除ram在List< byte>上的工作和字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文