Skip to content

Commit cefac53

Browse files
Replace ConcurrentHashMap with ConcurrentLongHashMap to avoid long boxing/unboxing
1 parent 0deb54b commit cefac53

File tree

3 files changed

+518
-6
lines changed

3 files changed

+518
-6
lines changed

create-export-package-metadata-pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
</execution>
3939
</executions>
4040
</plugin>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-compiler-plugin</artifactId>
44+
<configuration>
45+
<source>8</source>
46+
<target>8</target>
47+
</configuration>
48+
</plugin>
4149
</plugins>
4250
</build>
4351

src/com/sun/jna/Memory.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222
*/
2323
package com.sun.jna;
2424

25+
import com.sun.jna.internal.Cleaner;
26+
import com.sun.jna.internal.ConcurrentLongHashMap;
27+
2528
import java.io.Closeable;
2629
import java.lang.ref.Reference;
2730
import java.lang.ref.WeakReference;
2831
import java.nio.ByteBuffer;
2932
import java.util.ArrayList;
3033
import java.util.Collection;
31-
import java.util.Map;
32-
import java.util.concurrent.ConcurrentHashMap;
33-
34-
import com.sun.jna.internal.Cleaner;
3534

3635
/**
3736
* A <code>Pointer</code> to memory obtained from the native heap via a
@@ -53,8 +52,8 @@
5352
*/
5453
public class Memory extends Pointer implements Closeable {
5554
/** Keep track of all allocated memory so we can dispose of it before unloading. */
56-
private static final Map<Long, Reference<Memory>> allocatedMemory =
57-
new ConcurrentHashMap<>();
55+
private static final ConcurrentLongHashMap<Reference<Memory>> allocatedMemory =
56+
new ConcurrentLongHashMap<>();
5857

5958
private static final WeakMemoryHolder buffers = new WeakMemoryHolder();
6059

0 commit comments

Comments
 (0)