Skip to content
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

Memory.dispose() does not remove "this" from the allocatedMemory map #697

Closed
AgnetaWalterscheidt opened this issue Aug 30, 2016 · 1 comment

Comments

@AgnetaWalterscheidt
Copy link

Method Memory.dispose() frees the peer and sets it to 0. Afterwards it calls allocatedMemory.remove(this). This call does not find the Memory in the map: Memory is a subclass of Pointer which uses the peer for hashcode() and equals() and therefore "this" is no longer equal to the Memory that was put in the map.
This bug is easy to fix by first calling allocatedMemory.remove(this) and then setting the peer to 0.

@twall
Copy link
Contributor

twall commented Aug 30, 2016

Good catch. Could you provide a PR with the fix and an associated test?

On Tue, Aug 30, 2016 at 3:33 AM, AgnetaWalterscheidt <
[email protected]> wrote:

Method Memory.dispose() frees the peer and sets it to 0. Afterwards it
calls allocatedMemory.remove(this). This call does not find the Memory in
the map: Memory is a subclass of Pointer which uses the peer for hashcode()
and equals() and therefore "this" is no longer equal to the Memory that was
put in the map.
This bug is easy to fix by first calling allocatedMemory.remove(this) and
then setting the peer to 0.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#697, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAuMrTUjJYafXGniw4wqiEDHC1hud0XGks5qk9y0gaJpZM4JwOmU
.

mstyura pushed a commit to mstyura/jna that referenced this issue Sep 9, 2024
Motivation:

These methods should be marked as private-package as its arguments are
also package-private

Modifications:

Fix visibility

Result:

Cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants