Nokia Active Member Licensed User Longtime User Apr 6, 2016 #1 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 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?
Nokia Active Member Licensed User Longtime User Apr 6, 2016 #2 I can see from task menu every time I encrypt a file it adds memory, but does not release it.. Upvote 0
somed3v3loper Well-Known Member Licensed User Longtime User Apr 7, 2016 #3 What are you using for encryption ? You might be missing some Release function ? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Apr 7, 2016 #4 It is possible to increase the heap size. See the last section in this tutorial: https://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/#content However it sounds like there is a memory leak in your solution. Upvote 0
It is possible to increase the heap size. See the last section in this tutorial: https://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/#content However it sounds like there is a memory leak in your solution.
Nokia Active Member Licensed User Longtime User Apr 7, 2016 #5 somed3v3loper said: What are you using for encryption ? You might be missing some Release function ? Click to expand... jB4XEncryption Library Upvote 0
somed3v3loper said: What are you using for encryption ? You might be missing some Release function ? Click to expand... jB4XEncryption Library
Nokia Active Member Licensed User Longtime User Apr 7, 2016 #6 Erel said: It is possible to increase the heap size. See the last section in this tutorial: https://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/#content However it sounds like there is a memory leak in your solution. Click to expand... How can I track the memory leak? I did change the Heap size and was able to encrypt 155 mb file and up to 425 mb worth of a few files.. Upvote 0
Erel said: It is possible to increase the heap size. See the last section in this tutorial: https://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/#content However it sounds like there is a memory leak in your solution. Click to expand... How can I track the memory leak? I did change the Heap size and was able to encrypt 155 mb file and up to 425 mb worth of a few files..
Erel B4X founder Staff member Licensed User Longtime User Apr 7, 2016 #7 You can use a profiler to check for memory leaks: https://www.b4x.com/android/forum/threads/memory-leak.35729/#post-209766 Upvote 0
You can use a profiler to check for memory leaks: https://www.b4x.com/android/forum/threads/memory-leak.35729/#post-209766
Nokia Active Member Licensed User Longtime User Apr 7, 2016 #8 when I try to use the try and catch to get the message nothing happens. ... no message and the app still closes.. Upvote 0
when I try to use the try and catch to get the message nothing happens. ... no message and the app still closes..
Erel B4X founder Staff member Licensed User Longtime User Apr 8, 2016 #9 You cannot catch out of memory errors. Upvote 0
Nokia Active Member Licensed User Longtime User Apr 8, 2016 #10 Erel said: You cannot catch out of memory errors. Click to expand... what would you normally do then? 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. is there a way in code to check available memory? Upvote 0
Erel said: You cannot catch out of memory errors. Click to expand... what would you normally do then? 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. is there a way in code to check available memory?
Erel B4X founder Staff member Licensed User Longtime User Apr 10, 2016 #11 You can use this code to get the reported max heap size: Code: Copy Sub MaxHeapSize As Long Dim jo As JavaObject Return jo.InitializeStatic("java.lang.Runtime").RunMethodJO("getRuntime", Null).RunMethod("maxMemory", Null) End Sub Nokia said: what would you normally do then? Click to expand... You should avoid this situation. Recovering from out of memory errors is problematic. Upvote 0
You can use this code to get the reported max heap size: Code: Copy Sub MaxHeapSize As Long Dim jo As JavaObject Return jo.InitializeStatic("java.lang.Runtime").RunMethodJO("getRuntime", Null).RunMethod("maxMemory", Null) End Sub Nokia said: what would you normally do then? Click to expand... You should avoid this situation. Recovering from out of memory errors is problematic.
Nokia Active Member Licensed User Longtime User Apr 14, 2016 #12 Erel said: You can use this code to get the reported max heap size: Code: Copy 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. Click to expand... does this code give you the max heap size the app is using or does it give you the max that is available beside what the app is using? or does it give you how much memory the computer is running? Upvote 0
Erel said: You can use this code to get the reported max heap size: Code: Copy 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. Click to expand... does this code give you the max heap size the app is using or does it give you the max that is available beside what the app is using? or does it give you how much memory the computer is running?
Erel B4X founder Staff member Licensed User Longtime User Apr 15, 2016 #13 See the exact documentation here: https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#maxMemory() 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. Upvote 0
See the exact documentation here: https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#maxMemory() 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.
derez Expert Licensed User Longtime User Apr 16, 2017 #14 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. Upvote 0
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.
Daestrum Expert Licensed User Longtime User Apr 16, 2017 #15 Have a look at this post https://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/ Erel explains how to use #VirtualMachineArgs towards the end of post #1 Upvote 0
Have a look at this post https://www.b4x.com/android/forum/threads/parsing-huge-text-files.34923/ Erel explains how to use #VirtualMachineArgs towards the end of post #1
derez Expert Licensed User Longtime User Apr 17, 2017 #16 Thank you Daestrum, It solves the problem when running from the IDE but Erel writes there : Note that #VirtualMachineArgs attribute only affects the program when you run it from the IDE. Click to expand... 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. Upvote 0
Thank you Daestrum, It solves the problem when running from the IDE but Erel writes there : Note that #VirtualMachineArgs attribute only affects the program when you run it from the IDE. Click to expand... 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.
Daestrum Expert Licensed User Longtime User Apr 17, 2017 #17 If you find the setting removes the error, you can supply the same parameters when the user runs the jar. If you start the jar from a batch file just add the same parameters as the VirtualMachineArgs. I don't think you can change it from within a jar, as by that stage the JVM has been created. Upvote 0
If you find the setting removes the error, you can supply the same parameters when the user runs the jar. If you start the jar from a batch file just add the same parameters as the VirtualMachineArgs. I don't think you can change it from within a jar, as by that stage the JVM has been created.