Oh you got 5.3.5 running? awesome.
on the 150 bytes allocation in function NewtonWorld.Update(ForceAndTorque callback)
as far as I can tell this is the creation of the callback itself.
It seems C# makes delegate method call to unmanaged functions is by making a runtion C# objects, and coping the piece of code that is the glue that the call back can call.
It seems that this ForceAndTorque callback is the same as: new ForceAndTorque callback
maybe we can cache the call back into a local private variable.
I had a similar problem with the calling GetComponets<type> that creates a run time object. I was reading some of eth C# optimization tricks, and I have a hard time determine whet
new Type crate a what the they call a Boxed Object, (for what I can see a Boxed object is an object that is crated on the stack, and then is converted to a Garbage collected objects.
for example
Vector3 = new Vector (1, 2, 3)
is on the Stack, but if another object takes a reference that is become a Memory objects and that triggers the garbage collector.
This sound to me really bad, because in the end C# order to get high performance C# code the programmer has to be aware of more internals of the memory system that you do in C++.
anyway I tried to caching the Delegate into a variable like this.
- Code: Select all
private OnWorldUpdateCallback m_onWorldCallcak = new OnWorldUpdateCallback(OnWorldUpdate);
but I get this error.
2>------ Build started: Project: NewtonPlugin, Configuration: Debug Any CPU ------
2>C:\Users\jjerez\Downloads\NewtonUnityPlugin\NewtonPlugin\NewtonWorld.cs(124,80,124,93): error CS0236: A field initializer cannot reference the non-static field, method, or property 'NewtonWorld.OnWorldUpdate(float)'
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This Is why I suspect that Delegate are in fact memory allocated runtime C# objects.
I have no idea if we will be about to avoid that, but if we keep it to a minimum maybe we can live with it.
anyway I am now start adding the Joints.
My major problem now is that I have not figure out how to step in the script in debug mode, are you able to do that?
I guess one way if to recreate the project in MonoDeveloper only for debug purposes.