Hi all,
I wrote a quick and dirty sub to check hash signatures for downloaded packages.
It worked well against 500/600MB iso images, but failed with the following error trace when I attempted to calculate the hash from the 1.4GB Ubuntu 16.04.1 iso image.
I'm aware of the "-Xmx" java option but I'd like to know if there's something we can do in code to overcome the problem. I mean, something like instructing the chain InputStream-InputStreamToBytes-GetMessageDigest to work on chunks of data.
TIA
udg
I wrote a quick and dirty sub to check hash signatures for downloaded packages.
It worked well against 500/600MB iso images, but failed with the following error trace when I attempted to calculate the hash from the 1.4GB Ubuntu 16.04.1 iso image.
main._checksha1 (java line: 84)
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3236)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
at anywheresoftware.b4a.objects.streams.File.Copy2(File.java:357)
at anywheresoftware.b4a.keywords.Bit.InputStreamToBytes(Bit.java:94)
at b4j.example.main._checksha1(main.java:84)
at b4j.example.main._appstart(main.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$55/1964646456.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1567581361.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$50/842889876.run(Unknown Source)
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3236)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
at anywheresoftware.b4a.objects.streams.File.Copy2(File.java:357)
at anywheresoftware.b4a.keywords.Bit.InputStreamToBytes(Bit.java:94)
at b4j.example.main._checksha1(main.java:84)
at b4j.example.main._appstart(main.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:38)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.LauncherImpl$$Lambda$55/1964646456.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1567581361.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$50/842889876.run(Unknown Source)
I'm aware of the "-Xmx" java option but I'd like to know if there's something we can do in code to overcome the problem. I mean, something like instructing the chain InputStream-InputStreamToBytes-GetMessageDigest to work on chunks of data.
TIA
udg