我已经创建了一个基本的、默认的ASP.NET 5项目。我有一个控制器
var engine = new V8ScriptEngine();
并返回一些模拟json。当我刷新页面某些次数时,我得到
堆设置中的致命错误 分配失败-内存不足的进程
以及跟随堆栈跟踪
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at V8Isolate.Create(StdString* , V8IsolateConstraints* , Boolean , Int32 )
at Microsoft.ClearScript.V8.V8IsolateProxyImpl..ctor(String gcName, V8RuntimeConstraints gcConstraints, Boolean enableDebugging, Int32 debugPort)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Microsoft.ClearScript.V8.V8Proxy.CreateImpl[T](Object[] args)
at Microsoft.ClearScript.V8.V8IsolateProxy.Create(String name, V8RuntimeConstraints constraints, Boolean enableDebugging, Int32 debugPort)
at Microsoft.ClearScript.V8.V8Runtime..ctor(String name, V8RuntimeConstraints constraints, V8RuntimeFlags flags, Int32 debugPort)
at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(V8Runtime runtime, String name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, Int32 debugPort)
at Microsoft.ClearScript.V8.V8ScriptEngine..ctor()
我试着用dotMemory
查看内存。每次我刷新页面时,都会创建一个引擎,并将2MB的ram添加到非托管内存中。当它达到一定的限制时,就会像上面解释的那样崩溃。只要在达到限制之前单击force,内存就会下降,我可以再次使用该页面。
我的问题是:为什么GC一开始就不处理这个问题?在每个请求之后,对象都可以被释放,如果我强制GC这样做的话。我会说,如果我几乎没有记忆,但我可以用GC收回它,它会这样做。
我怎么解决这个问题?也许添加更多的内存会有所帮助,但我也不知道如何做到这一点。如果GC永远不会清理那些对象,那么无论如何它都会中断。
在运行Kestrel (dnx web
)和IIS
时也会发生同样的情况。我的框架设置为"dnx46“
这是我的dnx版本
$ dnx --version
Microsoft .NET Execution environment
Version: 1.0.0-rc1-16231
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 10.0
Runtime Id: win10-x86
ClearScript版本是"ClearScript.V8": "5.4.3"
发布于 2016-05-23 11:02:34
https://stackoverflow.com/questions/37387363
复制相似问题