VB6 Memory Limitations

梦想的初衷 提交于 2020-01-04 07:02:47

问题


I'm currently supporting a VB6 application (that we are replacing, but it's a slow process!) that is running on several servers. Can anyone tell me please what the maximum amount of memory of VB6 process can address is? We are using a variety of operating systems:

  • Windows Server 2003 32bit
  • Windows Server 2008 64bit
  • Windows Server 2008 R2 64bit

I've tried using resources like this: https://blogs.msdn.microsoft.com/tom/2008/04/10/chat-question-memory-limits-for-32-bit-and-64-bit-processes/

But I'm skeptical if this is accurate due to it discussing .NET based applications, however I can't find anything more on point than this.


回答1:


It is hard to take these "What if Superman got in a fight with God" questions too seriously. Long before this becomes a concern you should have moved from memory-resident data structures to a disk file or a database anyway.

But even without linking with /LARGEADDRESSAWARE and booting into 3GB mode a VB6 program can address quite a bit of data on 32-bit Windows.

Option Explicit

Private Sub Main()
    Const MAX_BYTES As Long = &H63700000
    Dim Bytes() As Byte

    ReDim Bytes(MAX_BYTES)
    Bytes(MAX_BYTES) = 255
    MsgBox "Success" & vbNewLine & vbNewLine _
         & "Bytes(MAX_BYTES) = " & CStr(Bytes(MAX_BYTES)) & vbNewLine & vbNewLine _
         & "MAX_BYTES = " & Format$(MAX_BYTES, "#,##0")
End Sub

Result:

Success

Bytes(MAX_BYTES) = 255

MAX_BYTES = 1,668,284,416

The linked blog post is correct in pointing out the limitations of a .Net process and their inability to cope with using large amounts of data. Scripting engines like .Net just are not built for these things, and don't underestimate the overhead of the gigantic libraries even the simplest .Net program drags into its address space.



来源:https://stackoverflow.com/questions/44762556/vb6-memory-limitations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!