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

Replaced unused WeakReference with Boolean in Memory.allocatedMemory #1233

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/com/sun/jna/Memory.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*/
package com.sun.jna;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -54,8 +52,8 @@
*/
public class Memory extends Pointer {
/** Keep track of all allocated memory so we can dispose of it before unloading. */
private static final Map<Memory, Reference<Memory>> allocatedMemory =
Collections.synchronizedMap(new WeakHashMap<Memory, Reference<Memory>>());
private static final Map<Memory, Boolean> allocatedMemory =
Collections.synchronizedMap(new WeakHashMap<Memory, Boolean>());

private static final WeakMemoryHolder buffers = new WeakMemoryHolder();

Expand Down Expand Up @@ -115,7 +113,7 @@ public Memory(long size) {
if (peer == 0)
throw new OutOfMemoryError("Cannot allocate " + size + " bytes");

allocatedMemory.put(this, new WeakReference<Memory>(this));
allocatedMemory.put(this, Boolean.TRUE);
}

protected Memory() {
Expand Down