reduce memory footprint: old generation by 100 MB

This reduces the size of the old generation by 100MB (300MB down to
200MB). Unfortunately the total JVM size didn't change and is still
512MB.

Doc stores the path as byte array instead of Path.
This commit is contained in:
2017-11-18 10:39:01 +01:00
parent cc49a8cf2a
commit f2868fcc1b
2 changed files with 32 additions and 5 deletions

View File

@@ -1,17 +1,21 @@
package org.lucares.pdb.datastore;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.lucares.pdb.api.Tags;
public class Doc {
private final Tags tags;
private final Path path;
private final byte[] path;
//private final Path path;
public Doc(final Tags tags, final Path path) {
super();
this.tags = tags;
this.path = path;
this.path = path.toString().getBytes(StandardCharsets.UTF_8);
//this.path=path;
}
public Tags getTags() {
@@ -19,12 +23,13 @@ public class Doc {
}
public Path getPath() {
return path;
return Paths.get(new String(path, StandardCharsets.UTF_8));
//return path;
}
@Override
public String toString() {
return "Doc [tags=" + tags + ", path=" + path + "]";
return "Doc [tags=" + tags + ", path=" + getPath() + "]";
}
}

View File

@@ -1,5 +1,8 @@
package org.lucares.memory;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -30,7 +33,7 @@ public class MemoryScale {
private static Object createObject(){
String key = "minimap";
String key = "pathAsUtf8";
switch (key) {
case "minimap":
return createMinimap();
@@ -38,12 +41,31 @@ public class MemoryScale {
return createString();
case "linkedHashMap":
return createLinkedHashMap();
case "path":
return createPath("C:\\pdb\\dataNew\\storage\\0\\4\\3n-5k_0-5l_2-1L_4-4n_3w-5h_6-7$.pdb");
case "pathAsString":
return createPathAsString("C:\\pdb\\dataNew\\storage\\0\\4\\3n-5k_0-5l_2-1L_4-4n_3w-5h_6-7$.pdb");
case "pathAsUtf8":
return createPathAsUtf8("C:\\pdb\\dataNew\\storage\\0\\4\\3n-5k_0-5l_2-1L_4-4n_3w-5h_6-7$.pdb");
default:
return null;
}
}
private static Object createPathAsUtf8(String string) {
// TODO Auto-generated method stub
return string.getBytes(StandardCharsets.UTF_8);
}
private static String createPathAsString(String string) {
return string.replace("C", "c");
}
private static Path createPath(String string) {
return Paths.get(string);
}
private static Object createMinimap() {
final MiniMap<String, String> map = new MiniMap<>();