Finalization and CNI
Craig A. Vanderborgh
craigv@voxware.com
Tue Jun 10 20:56:00 GMT 2003
Hello All:
I am getting started with CNI programming and I have a question. I am a
seasoned JNI programmer getting into CNI for the first time and I have
some questions about memory management.
The main question is simply this - how does it work? Let's say, for
example, that I have the following CNI program:
HelloWorld.java:
class HelloWorld {
public native void print();
public static void main(String[] args) {
HelloWorld hw = new HelloWorld();
hw.print();
System.out.println("Hello World: DONE");
}
}
include <gcj/cni.h>
#include <stdio.h>
#include "HelloWorld.h"
void HelloWorld::print() {
printf("Hello, world from CNI!\n");
void *alloc = new char[1024];
}
Presumably "alloc" is going to be leaked, correct? Is the correct thing
to do to put the deallocation stuff into the destructor for the
HelloWorld class? Would my destructor then get called at some point?
Any words about how memory management works in the CNI world would be
greatly appreciated. Any pointers to docs, etc. would be nice also
because I have not been able to find much on this topic.
TIA
craig vanderborgh
voxware incorporated
More information about the Java
mailing list