I get this error when trying to encrypt a file over 100 mb or trying to encrypt to many files at the same time. Is there a way to tell the app to get or set a bigger heap space?
or could this be from a memory leak from the encryption?
I have put a size restriction on how big a file that can be encrypted but I have noticed.. if you don't have a full dedicated 1024 mb of ram that it will show the out of memory error on a smaller file. on my laptop with 3 gig ram I can run 250mb file but on desktop with 2 gig of ram. I can only do a 100 mb file.
You can use this code to get the reported max heap size:
B4X:
Sub MaxHeapSize As Long
Dim jo As JavaObject
Return jo.InitializeStatic("java.lang.Runtime").RunMethodJO("getRuntime", Null).RunMethod("maxMemory", Null)
End Sub
You can use this code to get the reported max heap size:
B4X:
Sub MaxHeapSize As Long
Dim jo As JavaObject
Return jo.InitializeStatic("java.lang.Runtime").RunMethodJO("getRuntime", Null).RunMethod("maxMemory", Null)
End Sub
You should avoid this situation. Recovering from out of memory errors is problematic.
It gives you the maximum heap size that is available for the current process. It is not really related to the physical memory available. You can use the jvm parameters to ask for a higher limit.
Is it possible to change the max mem size from the b4j application ? I checked the status and it is 256MB and I would like to increase it in a special case that needs more.
I have checked and it is correct so it is not a solution for a user that gets the jar file.
I need a solution that will change the heap as part of the jar file code.