调用一个过程,在过程中用一个数组读入文件内容。当读过几个文件后,再读一个几M的大文件,出现内存溢出错误。先读大文件则正常执行。似乎是数组没有释放,为什么?怎么办?  Dim Filenr As Integer
  Dim ByteArray() As Byte
  
  'Open the source file and read the content
  'into a bytearray
  Filenr = FreeFile
  Open SourceFile For Binary As #Filenr
  ReDim ByteArray(0 To LOF(Filenr) - 1)
  Get #Filenr, , ByteArray()
  Close #Filenr

解决方案 »

  1.   

    那就用完了释放呗
    erase bytearray
      

  2.   

    cuizm(射天狼) :
    试了,依然如故。还有其他办法吗?
      

  3.   

    你就是这些代码吗?应该不会有问题啊!!Dim Filenr As Integer
        Dim ByteArray() As Byte
        
        'Open the source file and read the content
        'into a bytearray
        Filenr = FreeFile()
        Open SourceFile For Binary As #Filenr
        ByteArray = InputB(LOF(1), #1)
        Close #Filenr
        
        Erase ByteArray我读了一个三兆多的文件,读了十几次,也没问题啊~~
      

  4.   

    我读的是9M的大文件。
    出错时,停留在ReDim ByteArray(0 To LOF(Filenr) - 1)语句。
      

  5.   

    在其他程序段文件数据处理中,有大量CopyMemory用于加密。
    压缩加密量之后问题解决。
    谢谢各位。