ikorin24/UnmanagedArray

Any way to use it in struct to keep the struct unmanaged?

Closed this issue · 3 comments

I tried this package, the UnmanagedArray class itself is managed, so when put into a struct, the struct can no longer be unmanaged.

Any plan to support this? I'm not sure if this can be done in a beautiful way.

Do you want a new type of UnmanagedArray made of struct ?

Unmanaged memory must be released, or a memory leak will occur. Even if you forget to do that with the Dispose method, the class can always release memory with the finalizer. However, struct does not have the finalizer.
I can support UnmanagedArray made of struct, but it is dangerous a little in the case that you forget to call 'Dispose()'.

Please let me know if you have any additional information or a sample code of your problem you can share.

I use it in a part time toy project, I want to explore something I'm not that familiar with.

The project is to rewrite lua5.4 in C#, I know it can be done in managed way like many other repos here in Github. I just want to write it in unmanaged code like the lua source code in C do. So I'm really not sure if it's needed/good practice/good in performance.

It's just for learning and exploring.

OK, that sounds interesting, but I have no plan to support your suggestion yet. I'm sorry.

If you need it in your project, copy the source code of UnmanagedArray and change 'class' into 'struct'. Then remove the finalizer. It may work well.

Thank you, AxelHu