vba ACCESS 2010 系统资源超标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19550367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:01:24  来源:igfitidea点击:

ACCESS 2010 System Resource Exceeded

formsvbams-accessaccess-vbams-access-2010

提问by Diego Garcia Vieira

My team were working with access 2000, where we have our MDB project. This application(ERP) could open around 20 access forms. After we decide migrate our entire system to Access 2010 to its new format, *.accdb; we are having this trouble with less memory, around 100mb nowadays.

我的团队正在使用 access 2000,我们在那里有我们的 MDB 项目。这个应用程序(ERP)可以打开大约 20 个访问表单。在我们决定将我们的整个系统迁移到 Access 2010 后,使用它的新格式 *.accdb;我们在内存较少的情况下遇到了这个问题,现在大约 100MB。

Is there any workaround, any path i could follow to increase my access 2010 project memory limit.

是否有任何解决方法,我可以遵循的任何路径来增加我的访问 2010 项目内存限制。

Problem's Flow: We put login and password in the initial form, and start opening forms(form from access forms, literally). When around 10 forms, the memory used by acess 2010 reachs 107mb, and when we open the next form, the system crash with the following error: "3035 Description System resource exceeded"

问题流程:我们将登录名和密码放在初始表单中,然后开始打开表单(从访问表单中获取的表单,字面意思)。当大约10个表单时,access 2010使用的内存达到107mb,当我们打开下一个表单时,系统崩溃并出现以下错误:“3035 描述系统资源超出”

回答by Mint

The issue is caused by 32 bit Access exceeding the 32 bit windows Virtual Memory limit of 2GB per app. I don't know why this issue does not crop up on Windows XP (didn't have time to test it).

该问题是由 32 位访问超过每个应用程序 2GB 的 32 位 Windows 虚拟内存限制引起的。我不知道为什么这个问题在 Windows XP 上没有出现(没有时间测试)。

You can track VM usage either through Performance Monitor or through code in the access app. You will see that as forms open the VM usage creeps up until access balks.

您可以通过性能监视器或访问应用程序中的代码跟踪 VM 使用情况。您将看到,随着表单打开,VM 使用率逐渐上升,直到访问受阻。

The solution is to switch to Access 64 bit on windows 64bit. Keep in mind that if you have external dll calls they need to be rewritten for 64 bit. Also ActiveX controls need to be 64 bit.

解决办法是在windows 64bit上切换到Access 64位。请记住,如果您有外部 dll 调用,则需要将它们重写为 64 位。ActiveX 控件也需要是 64 位的。



Code to track VM

跟踪虚拟机的代码

Declare PtrSafe Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)

Public Type MEMORYSTATUS
   dwLength As Long
   dwMemoryLoad As Long
   dwTotalPhys As Long
   dwAvailPhys As Long
   dwTotalPageFile As Long
   dwAvailPageFile As Long
   dwTotalVirtual As Long
   dwAvailVirtual As Long
End Type

Function ReturnVirtualMemory() As Long

    Dim Mem as MEMORYSTATUS

    Mem.dwLength = Len(Mem)
    GlobalMemoryStatus Mem

    ReturnVirtualMemory = Mem.dwTotalVirtual - Mem.dwAvailVirtual
End Function

回答by szayeri

This may help as did for me: Activate system managed paging on all your drives. For this,

这可能对我有帮助:在所有驱动器上激活系统管理的分页。为了这,

  1. RightClick on 'My Computer' icon and select 'Properties',
  2. Go to 'Advanced system settings'>Advanced>Settings>Advanced>Change,
  3. Uncheck 'Automatically manage paging ...' and select all your drives one by one and set 'System managed size' for each.
  4. Press [OK] and you're done.
  1. 右键单击“我的电脑”图标并选择“属性”,
  2. 转到“高级系统设置”>“高级”>“设置”>“高级”>“更改”,
  3. 取消选中“自动管理分页...”并一个一个选择所有驱动器并为每个驱动器设置“系统管理大小”。
  4. 按[确定],你就完成了。

Example Screenshot

示例截图

回答by TesseractE

Building off of the VM tracking code provided by Mint, I've made a sort of 'Early warning' system for my application that warns you when the VM is approaching a point where it'll start causing problems and recommend a reboot. It's slightly annoying, but until someone comes up with a better solution to 32-Bit Office running in a 64-Bit OS environment, it'll have to do.

基于 Mint 提供的 VM 跟踪代码构建,我为我的应用程序制作了一种“早期警告”系统,当 VM 接近开始引起问题的点时会向您发出警告并建议重新启动。这有点烦人,但除非有人为在 64 位操作系统环境中运行的 32 位 Office 提出更好的解决方案,否则它必须这样做。

ReturnVM:Returns the Virtual Memory usage in GB, triggers alert if it's over 1.425GB. I've found that this works for my application giving as much time between restarts while still allowing some leeway to finish work before restarting. Feel free to adjust as needed.

ReturnVM:以 GB 为单位返回虚拟内存使用情况,如果超过 1.425GB 则触发警报。我发现这适用于我的应用程序,在重新启动之间提供尽可能多的时间,同时仍然允许在重新启动之前有一些余地来完成工作。根据需要随意调整。

os_Restart:Writes a batch file that kills the active Access process, deletes the leftover laccdb file and restarts the application (provided everything's on the user's desktop). After writing the file, it executes the batch. Another function deletes this file on application start.

os_Restart:写入一个批处理文件,杀死活动的 Access 进程,删除剩余的 laccdb 文件并重新启动应用程序(前提是用户桌面上的所有内容)。写入文件后,它执行批处理。另一个函数在应用程序启动时删除此文件。

TempVars!tv_WinUID= Environ("USERNAME")

TempVars!tv_WinUID= 环境(“用户名”)

Function ReturnVM() As Double

    Dim Mem As MEMORYSTATUS
    Dim Result As Integer

    Mem.dwLength = Len(Mem)
    GlobalMemoryStatus Mem

    ReturnVM = Format((Mem.dwTotalVirtual - Mem.dwAvailVirtual) / 1073741824, "0.000")

    Debug.Print ReturnVM & " GB of VM used."

    If (ReturnVM >= 1.425) Then
      DoEvents
      Result = MsgBox("Office Virtual Memory usage is approaching the pre-set limit." & vbCrLf & vbCrLf & "To prevent a possible crash, please click 'OK' to restart immediately." & vbCrLf & vbCrLf & "You may click 'Cancel' to finish what you're working on, but if you do, please restart the application as soon as possible.", vbOKCancel)
      If (Result = vbOK) Then
        os_Restart
      End If
    End If

End Function

Public Function os_Restart()

    Dim fso As Object
    Dim oFile As Object
    Dim BatchContents As String

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set oFile = fso.CreateTextFile("C:\Users\" & TempVars!tv_WinUID & "\Desktop\RestartAccess.bat")

    BatchContents = "@echo Restarting Application..." & vbCrLf & _
                    "@echo off" & vbCrLf & _
                    "taskkill /f /im MSACCESS.EXE" & vbCrLf & _
                    "ping -n 6 127.0.0.1 > nul" & vbCrLf & _
                    "del " & Chr(34) & "C:\Users\" & TempVars!tv_WinUID & "\Desktop\Application.laccdb" & Chr(34) & vbCrLf & _
                    "start " & Chr(34) & Chr(34) & " " & Chr(34) & "C:\Users\" & TempVars!tv_WinUID & "\Desktop\Application.accdb" & Chr(34)

    DoEvents
    'Debug.Print BatchContents
    oFile.WriteLine BatchContents
    oFile.Close
    Set fso = Nothing
    Set oFile = Nothing

    Call Shell("C:\users\" & TempVars!tv_WinUID & "\Desktop\RestartAccess.bat")

End Function

回答by Christopher B

After months of frustration I have found a cause and a solution for this in both Access 2010 and Access 2013. Having Skype loaded in the background when running the program was causing the "System resource exceeded error" during both large queries and compact and repair.

经过数月的挫折,我在 Access 2010 和 Access 2013 中找到了一个原因和解决方案。在运行程序时在后台加载 Skype 导致在大型查询和压缩和修复期间出现“系统资源超出错误”。

If you still have problems run in windows xp compatibility mode

如果在 windows xp 兼容模式下运行仍有问题