This project is read-only.

Persistent V8ManagedObject property

Jun 2, 2016 at 8:11 AM
Persistent V8ManagedObject property

Hi,

I am using a tree data hierarchy. For example "Root.Category.SubCategory.Value".
I am using series of V8ManagedObject. "Category" is the property of "Root" and "SubCategory" is the property of "Category".
Properties are created dynamically in NamedPropertyGetter. If the property doesn't exist, V8ManagedObject instance is created and inserted into Properties.

JSProperty prop;
prop = new JSProperty(Engine.CreateValue(propObject), V8PropertyAttributes.DontDelete);
Properties.Add(name, prop);

I am calling V8Engine.Execute ciclically with different scripts. I am using following syntax:
"(function() {" + JSScript + "})()";

After short time application crash with exception 'System.AccessViolationException'. It seems that property is invalid.
I can check every time if the property is valid (IsWeakHandle and IsWeakManagedObject are false). If not, i can recreate the property.
It is working better but producing memory leak and ist not 100% stable. Sometimes crash.
Unfortunately, I can't dispose Engine after every Execute. It is producing even bigger memory leak.
How to make realy persistent property?
Jun 2, 2016 at 9:06 AM
Hi, could be any number of things. I'll need the source to test with. Just zip it up and send me a link, thanks.
Jun 2, 2016 at 10:58 AM
Edited Jun 2, 2016 at 12:08 PM
Hi,

thank you for fast reply. I have made simple test application. It demonstrate memory leak by using V8ManagedObject property.
Link
Try enable "Thread.Sleep(100);". It simulates other work and make memory leak bigger.
This application also "freezed" one time. Function Execute did not return.

[Edit:]
"freeze" is in function CreateNewDynamicObject by calling Engine.CreateObjectTemplate().CreateObject<DynamicDataSourceBase>();

I thing, I am making something wrong.