-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect.GetDomains throw System.BadImageFormatException #4
Comments
https://github.com/libvirt/libvirt-csharp/blob/c5a8a21027f52450aff24eeba5db0d49316bd133/NativeFunctions.cs#L30 tried to import |
and in driver implemention:
which memory is allocated by https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-new0 |
@WenceyWang the bug is on Windows only? |
seems yes, Marshal.FreeHGlobal will call free in libc. |
So, if you comment |
For But for other tests. It's not so well. there are a lot of problems, I'll PR after I fixed things up.
|
I found that the problem is that Marshal to string:
https://stackoverflow.com/questions/370079/pinvoke-for-c-function-that-returns-char/370519 |
I think we have to read strings using Marshal.PtrToStringAuto and then free memory by P/Invoke free in And |
And
will cause memory leak. |
Marshal.FreeHGlobal(ptrDomains);
callsKernel32.LocalFree
instead offree
in vcrt on Windows and causeSystem.BadImageFormatException
The text was updated successfully, but these errors were encountered: