English 中文(简体)
VB6应用程序内存不足错误
原标题:Out of memory error in VB6 application
  • 时间:2010-10-15 14:12:02
  •  标签:
  • vb6

Before anyone says it, I know this isn t the way it should be done, but it s the way it was done and I m trying to support it without rewriting it all.
I can assure you this isn t the worst bit by far.

The problem occurs when the application reads an entire file into a string variable. Normally this work OK because the files are small, but one user created a file of 107MB and that falls over.

intFreeFile = FreeFile
Open strFilename For Binary Access Read As intFreeFile
ReadFile = String(LOF(intFreeFile), " ")
Get intFreeFile, , ReadFile
Close intFreeFile

现在,它不会倒在绳子上

ReadFile = String(LOF(intFreeFile), " ")

但在

Get intFreeFile, , ReadFile

那么,这里发生了什么,String肯定已经完成了内存分配,那么为什么它会抱怨Get上的内存不足呢?

问题回答

通常,读取文件需要一些缓冲,这会占用空间。我在这里猜测,但我会考虑字节到字符转换所需的空间。VB6字符串为16位,但(二进制)文件为8位。文件内容需要107MB,转换后的结果需要214MB。字符串分配仅保留214 MB。

您不需要那个“GET”调用,只需删除它,您已经将文件放入字符串中,因此不需要使用GET调用。

ReadFile = Input(LOF(intFreeFile), intFreeFile)

I got the same error . And we just checked the taskmanager showing 100% resource usage . we found out one of the update application was taking too much ram memory and we just killed it. this solved the issue for me. One more thing was we gone in to config settings. START->RUN->MSCONFIG and go to startup tab and uncheck the application that looks like a updater application or some odd application that you dont use.





相关问题
Prevent windows from queuing shellexecute requests

Win.ShellExecute 0, "open", "C:dirprogram.exe", "arguments", vbNullString, SW_SHOWNORMAL Win.ShellExecute 0, "open", "http://www.google.com", vbNullString, vbNullString, SW_SHOWNORMAL I want google....

Why is My Loop Only Deleting One File?

Using VB6 In a folder, i have n number of files, i want to delete a 0 kb files code Dim filename5 As String filename5 = Dir$(txtsourcedatabasefile & "*_*", vbDirectory) MsgBox filename5 Do ...

How to check the filesize?

Using VB6 I have the text file with different sizes, so i want to delete the file where filesize = 0 kb. How to make a vb6 code for deleting the 0 kb files. Need vb6 code Help

File Rename problem?

I m using VB6 and I have a folder where I have n number of files. I want to change the file extension to .txt. I used the code below to change the extension of all .fin files to .txt. Dim filename1 ...

Error 20728-F while in using Crystal Reports in VB6

I m using Crystal Reports in my VB6 project, but I m facing error while loading the report in crystalreport1.action=1; Please give me some solution for this problem. It is showing the error as Error ...

DllRegisterServer entry point was not found

When running my vb6 application I am getting error like, runtime error 53 : file not found: rscomclNoMsg.dll then i tried to register that dll from cmd line using regsvr32. Then I am getting ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签