[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] Memory free in libvirt JNA

At Thu, 11 Oct 2012 08:37:23 +0000,
Benjamin Wang (gendwang) wrote:
> Hi Claudio,
>    Sorry for my late response.
>    I have gone through Claudio's solution. It's good. But I think this is not a common solution. There are two points:
> 1. This solution must use Pointerbyreference to encapsulate the
>    Pointer. This is not clean.

Yes, as I said, this adds another level of indirection --- which is
pretty useless in Java.

> 2. Libvirt provides virFree method. But a common library could not
>    provide memory management functions.

Sorry, I don't get your point here.

> My proposal is as following:
> 1. Add a new Class Libc.java
> public interface Libc  extends Library{
> 	Libc INSTANCE = (Libc) Native.loadLibrary("c", Libc.class);
> 	public void free(Pointer p);
> }

Not every platform has a shared library called "c". On Windows this
would be msvcrt.dll for the Microsoft runtime. So, you would need to
branch on the platform to load whatever library seems appropriate.

Also, I just discovered that since version 3.3.0 JNA provides a public
free method itself.

Since I get crashes when using callback functions with JNA 3.2.7 in
certain circumstances it is better just to require a newer version of

I'll post a few patches with improvements and memory fixes tomorrow.

AV-Test GmbH, Henricistra├če 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19

Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]