Hey folks,
I'm using GeoIP2 version 2.15.0.
I realize this issue has been brought up before in the following links, but I'm still unable to get it working.
#123
https://stackoverflow.com/questions/59557001/maxmind-databasereader-java-heap-space
https://stackoverflow.com/questions/14876836/file-inside-jar-is-not-visible-for-spring
I'm building a Java spring boot application. This is my code to setup the Database Reader. Note - I am only creating the Database Reader ONCE, not per call.
ResourceLoader resourceLoader = new DefaultResourceLoader();
Resource resource = resourceLoader.getResource("classpath:/GeoLite2-City.mmdb");
DatabaseReader reader = new DatabaseReader.Builder(resource.getInputStream())
.fileMode(Reader.FileMode.MEMORY)
.withCache(new CHMCache())
.build();
However, when setting up the Database Reader I get this error:
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3236) ~[na:1.8.0_292]
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118) ~[na:1.8.0_292]
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) ~[na:1.8.0_292]
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153) ~[na:1.8.0_292]
at com.maxmind.db.BufferHolder.<init>(BufferHolder.java:52) ~[maxmind-db-2.0.0.jar!/:na]
at com.maxmind.db.Reader.<init>(Reader.java:90) ~[maxmind-db-2.0.0.jar!/:na]
at com.maxmind.geoip2.DatabaseReader.<init>(DatabaseReader.java:89) ~[geoip2-2.15.0.jar!/:2.15.0]
at com.maxmind.geoip2.DatabaseReader.<init>(DatabaseReader.java:62) ~[geoip2-2.15.0.jar!/:2.15.0]
at com.maxmind.geoip2.DatabaseReader$Builder.build(DatabaseReader.java:216) ~[geoip2-2.15.0.jar!/:2.15.0]
Note: This only happens when I package the app as a WAR file and deploy to AWS, but works fine on my local machine.
Because I'm accessing the .mmdb file in the WAR, I can't use resource.getFile() because a FileNotFoundException gets thrown. And when passing an InputStream into the DatabaseReader Builder (resource.getInputStream()), the Out of Memory Error gets thrown.
Been stuck on this for several days now, I must be missing something. Thanks in advance!
Hey folks,
I'm using GeoIP2 version 2.15.0.
I realize this issue has been brought up before in the following links, but I'm still unable to get it working.
#123
https://stackoverflow.com/questions/59557001/maxmind-databasereader-java-heap-space
https://stackoverflow.com/questions/14876836/file-inside-jar-is-not-visible-for-spring
I'm building a Java spring boot application. This is my code to setup the Database Reader. Note - I am only creating the Database Reader ONCE, not per call.
However, when setting up the Database Reader I get this error:
Note: This only happens when I package the app as a WAR file and deploy to AWS, but works fine on my local machine.
Because I'm accessing the .mmdb file in the WAR, I can't use resource.getFile() because a FileNotFoundException gets thrown. And when passing an InputStream into the DatabaseReader Builder (resource.getInputStream()), the Out of Memory Error gets thrown.
Been stuck on this for several days now, I must be missing something. Thanks in advance!