7 messages in net.java.dev.jna.usersRe: [jna-users] Finding Access violat...
FromSent OnAttachments
Thomas BörkelMay 21, 2008 8:07 am 
Timothy WallMay 22, 2008 1:41 pm 
Timothy WallMay 22, 2008 1:43 pm 
Thomas BörkelMay 22, 2008 11:53 pm 
Thomas BörkelMay 23, 2008 12:32 am 
Timothy WallMay 23, 2008 6:14 am 
Thomas BörkelMay 28, 2008 9:53 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Finding Access violationsActions...
From:Timothy Wall (twal@dev.java.net)
Date:May 23, 2008 6:14:25 am
List:net.java.dev.jna.users

On May 23, 2008, at 3:32 AM, Thomas Börkel wrote:

Here you are freeing native memory without first clearing the Java object which references it. "displayGroup" is depending on the sortedBuf pointer value. You should set displayGroup/displayGroups to null prior to freeing the native memory.

I do not understand quite what that would accomplish. This does not mean that the GC removes the object immediately and on the other hand, I am not using it anymore after freeing it.

In your posted code, it wouldn't have any effect other than to ensure that the Java object cannot be accessed. You can never tell what someone's omitted from posted code, though.

Or do I have to make a COPY of displayGroup.grpi3_name for storing in my own TreeSet domainGroups?

Java Strings are independent of the underlying native memory, so once the string is copied, the native memory may be disposed safely.

In the meantime, I discovered (by attaching WinDbg to other Java programs, like SwingSet2), that unhandled access violation seem to be normal in Java applications!

Perhaps the VM does some structured exception handling to catch expected access violations?

The heap corruption, that I got in my application is now gone, after I changed another function:

Glad to hear it. Can you summarize the issue (I don't think many folks would be able to glean the essential difference from reading the w32 API code...)? Perhaps something to be included in a FAQ for things to watch out for?