Delta 2.1
Delta 2.1
CC#
Created by Delta 2.1 on 1/21/2024 in #help
I've loaded CoreClr from hostFxr and it looks like the garbage Collector is not doing his job...
ok the third parameter of collect handle that GC.Collect(3, GCCollectionMode.Default, true);
9 replies
CC#
Created by Delta 2.1 on 1/21/2024 in #help
I've loaded CoreClr from hostFxr and it looks like the garbage Collector is not doing his job...
No description
9 replies
CC#
Created by Delta 2.1 on 1/21/2024 in #help
I've loaded CoreClr from hostFxr and it looks like the garbage Collector is not doing his job...
but it actually looks like that
9 replies
CC#
Created by Delta 2.1 on 1/21/2024 in #help
I've loaded CoreClr from hostFxr and it looks like the garbage Collector is not doing his job...
so the execepted output should look like that:
//print of the vec
finalized (when Gc.collect() is called)
invoking GC right here
//print of the vec
finalized (when Gc.collect() is called)
invoking GC right here
9 replies
CC#
Created by Delta 2.1 on 1/21/2024 in #help
I've loaded CoreClr from hostFxr and it looks like the garbage Collector is not doing his job...
interessting, here my C# side (shorted)
class Finalized : CriticalFinalizerObject
{
~Finalized()
{
Console.WriteLine("finalized");
}
}

static public class Class1
{
//little hack to use the host as a DLL (and support the host rename)
[UnmanagedCallersOnly]
static void Init(IntPtr textPTr, Int32 textLenght) //the setup
{
var hostName = Marshal.PtrToStringUTF8(textPTr, textLenght);
var assembly = Assembly.GetExecutingAssembly();
DllImportResolver resolver = (string libraryName, Assembly assembly, DllImportSearchPath? searchPath) => {
if (libraryName == "host")
return NativeLibrary.Load(hostName);
return IntPtr.Zero;
};
NativeLibrary.SetDllImportResolver(assembly, resolver);
}

//main loaded by rust side
[UnmanagedCallersOnly]
public static void Main()
{
var finalized = new Finalized(); //pur C# object with a finalizer

var vec = new Vec3I(); //this an unmanaged struct, from rust, just a small test
vec.x = 1;
vec.y = 2;
vec.z = 3;

vec.Print(); //this is bind to rust
}

[UnmanagedCallersOnly]
public static void Cleanup() //recently added cleanup method
{
GC.Collect(); //need else finalizer is never called !
Console.WriteLine("invoking GC right here");
}
}
class Finalized : CriticalFinalizerObject
{
~Finalized()
{
Console.WriteLine("finalized");
}
}

static public class Class1
{
//little hack to use the host as a DLL (and support the host rename)
[UnmanagedCallersOnly]
static void Init(IntPtr textPTr, Int32 textLenght) //the setup
{
var hostName = Marshal.PtrToStringUTF8(textPTr, textLenght);
var assembly = Assembly.GetExecutingAssembly();
DllImportResolver resolver = (string libraryName, Assembly assembly, DllImportSearchPath? searchPath) => {
if (libraryName == "host")
return NativeLibrary.Load(hostName);
return IntPtr.Zero;
};
NativeLibrary.SetDllImportResolver(assembly, resolver);
}

//main loaded by rust side
[UnmanagedCallersOnly]
public static void Main()
{
var finalized = new Finalized(); //pur C# object with a finalizer

var vec = new Vec3I(); //this an unmanaged struct, from rust, just a small test
vec.x = 1;
vec.y = 2;
vec.z = 3;

vec.Print(); //this is bind to rust
}

[UnmanagedCallersOnly]
public static void Cleanup() //recently added cleanup method
{
GC.Collect(); //need else finalizer is never called !
Console.WriteLine("invoking GC right here");
}
}
9 replies
CC#
Created by Delta 2.1 on 1/21/2024 in #help
I've loaded CoreClr from hostFxr and it looks like the garbage Collector is not doing his job...
look managed unmanaged method never call the GC, I a third method (i've a setup a DLLresolver to my host executable, the main function) and now I added a thrid function which call the GC by and finalizer are called now
9 replies
CC#
Created by Delta 2.1 on 12/16/2023 in #help
function pointer
Lambda and méthods can use data other than the parameters
30 replies
CC#
Created by Delta 2.1 on 12/16/2023 in #help
function pointer
I lose control over data used by the callback 🤨
30 replies
CC#
Created by Delta 2.1 on 12/16/2023 in #help
function pointer
8 times this, because pointers use 8 bytes, and delegate use much more
30 replies
CC#
Created by Delta 2.1 on 12/16/2023 in #help
function pointer
I believe 24k set of at least 10 pointers is too big 🤔
30 replies
CC#
Created by Delta 2.1 on 12/16/2023 in #help
function pointer
(I will have something like 150k of them in memory...)
30 replies
CC#
Created by Delta 2.1 on 12/16/2023 in #help
function pointer
delegate support references on the parameter, but they are way bigger than a function pointer
30 replies
CC#
Created by Delta 2.1 on 12/16/2023 in #help
function pointer
I don't need an array to all function at the same time, but call a function based on ID
30 replies
CC#
Created by Delta 2.1 on 12/16/2023 in #help
function pointer
delegate would be way to expensive for my case, I don't need any dynamic resolution, and must ensure that the function is static 😅
30 replies
CC#
Created by Delta 2.1 on 12/11/2023 in #help
embding C# for scripting in rust
I'm sorry if I'm a bit dry, it's just that I've been looking at how to implement this for months and months.
12 replies
CC#
Created by Delta 2.1 on 12/11/2023 in #help
embding C# for scripting in rust
both way, use C# as a scripting language like unity does
12 replies
CC#
Created by Delta 2.1 on 12/11/2023 in #help
embding C# for scripting in rust
I can pass function pointer and cast them in the C# side, but it get very ugly and unreadable
12 replies
CC#
Created by Delta 2.1 on 12/11/2023 in #help
embding C# for scripting in rust
and for my beloved [MethodImplAttribute(MethodImplOptions.InternalCall)], it exist with hostfxr/coreCLR, but only usable when COM API are defined (using C++/Cli, which isn't cross platfrom)
12 replies
CC#
Created by Delta 2.1 on 12/11/2023 in #help
embding C# for scripting in rust
(mono handle them easly)
12 replies
CC#
Created by Delta 2.1 on 12/11/2023 in #help
embding C# for scripting in rust
so it must be a way do deal with it 🤔
12 replies