Android Question The system is out of resources.

Tommaso

Member
Licensed User
Longtime User
Hi,
since b4a 10.2 upgrade when I try to compile I had an error

B4A Versione: 10.2
Java Versione: 11
Analisi del Codice. (2.25s)
Building folders structure. (0.12s)
Esecuzione azione personalizzata. (0.06s)
Compilazione del codice. (3.61s)
Compilazione del codice di layouts (0.34s)
Organizzazione Librerie. (0.00s)
(AndroidX SDK)
Generazione file R. (0.00s)
Compilazione del codice debugger. Error
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError

I've tried to change MaxRamForDex without success
anyone has the same issue? any hints or ideas on that?

Thanks in advance
Tommaso Honoré
 

Attachments

  • CompileError.txt
    95.5 KB · Views: 285

DonManfred

Expert
Licensed User
Longtime User
There is not enough memory left for the java compiler.
How many RAM do you have in your System? How many is FREE?
 
Upvote 0

Tommaso

Member
Licensed User
Longtime User
Try give more memory to java

Raise the value for MaxRamForDex in the B4A Ini file.
Tks DonManfred
I've tried to raise value until 20000 (by 1000) but without success, error has changed a little (I've attached)
 

Attachments

  • CompileError.txt
    95.4 KB · Views: 268
Upvote 0

Tommaso

Member
Licensed User
Longtime User
Searching on google I've found xss parameter
is there a way to set -xss parameter to javac, I would try to increase java stack trace memory
Thanks
 
Upvote 0

Tommaso

Member
Licensed User
Longtime User
Strange error. What exactly are you compiling? Have you added a lot of data into the code?

Does it happen with all projects?

Hi Erel,
I'm compiling a project application, and no, not all my projects have this issue.
What do you means with " Have you added a lot of data into the code? "

Thanks
Tommaso
 
Upvote 0

Tommaso

Member
Licensed User
Longtime User
Hi,
I've try to check log statement but not seems to be.
I can send you the project, for sure, is there a way to send you in private, maybe a mail?
Thanks in advance
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tried your program.

I got this error:

shell\src\com\palmosoft\palmoagenti\frmordine_subs_0.java:3736: error: code too large for try statement
catch (Exception e1358) {
^
1 error

It happens in Activity_Create of FRMOrdine. This sub, which is more than 2000 lines long, is too large. You are hitting a limitation of the underlying compiler.

I recommend you to split this project into several smaller projects and compile them as libraries. The main project will reference the compiled libraries (not B4XLibs).
It will be easier to maintain and compilation will work better and much faster.
 
Upvote 0

Tommaso

Member
Licensed User
Longtime User
Hi Erel,
yes you are right, I've seen it but even breaking frmordine_Load in smaller function it doesn't work (it give error "The system is out of resources")
And before b4a upgrade I did haven't this issue.
If you try to break frmordineActivity_create function in smaller (or cropping code) are you able to compile?

Thank you for support
 
Upvote 0

MMORETTI964

Member
Licensed User
Longtime User
I've tried myself to compile in aid to Tommaso.

As I've seen all tries he made this days (I've worked with assembly for a lot of years), so I supposed the problem was inside the code (and the translation of Java).

Interesting point, I've debugged as I made in the past when I have no debugger & no aid: delete one module at a times: after that, I discover it needs only a function to give me the stack overflow condition.

The offender code is:
"Else If" (nested)

I think Java haven't a similar keyword, so in my mind the interpretation java of this code is a classical:

if condition then
step1
else
if condition2 then
step2
... and so on.

So, in one piece of B4A code I've seen almost hundreds of "Else if"nested (perfectly valid in Basic environment and nice to look at, even if in this case should be better a "select case").

As B4A you have correctly nested in java, but, as javac compiles the nested code the stack overflows.

EDITED: After a while I try to deep more...

In release mode else if was traduced with "else if" this:
B4X:
//BA.debugLineNum = 1561;BA.debugLine="If Name = \"NumOrd\" Then";
if ((_name).equals("NumOrd")) {
//BA.debugLineNum = 1563;BA.debugLine="NumOrd = Function.CIntMia(Text.ToString)";
_numord = _function._cintmia /*int*/ (getActivityBA(),(Object)(_text.ToString()));
}else if((_name).equals("ListBase")) {
//BA.debugLineNum = 1565;BA.debugLine="ListBase = Function.CStrMia(Text.ToString)";
_listbase = _function._cstrmia /*String*/ (getActivityBA(),(Object)(_text.ToString()));
}else if(
and so on...

In debug mode instead B4A works with else and curly brakets (in debug maybe the need is different, sure @Erel made this for a good reason).

B4X:
RDebugUtils.currentLine=11010050;
//BA.debugLineNum = 11010050;BA.debugLine="If Name = \"NumOrd\" Then";
if ((_name).equals("NumOrd")) {
RDebugUtils.currentLine=11010052;
//BA.debugLineNum = 11010052;BA.debugLine="NumOrd = Function.CIntMia(Text.ToString)";
__ref._numord /*int*/  = _function._cintmia /*int*/ (getActivityBA(),(Object)(_text.ToString()));
}else
{RDebugUtils.currentLine=11010053;
//BA.debugLineNum = 11010053;BA.debugLine="Else If Name = \"ListBase\" Then";
if ((_name).equals("ListBase")) {
RDebugUtils.currentLine=11010054;
//BA.debugLineNum = 11010054;BA.debugLine="ListBase = Function.CStrMia(Text.ToString)";
__ref._listbase /*String*/  = _function._cstrmia /*String*/ (getActivityBA(),(Object)(_text.ToString()));
}else

The parser seems recursively call a function every "if then else".
The error give the idea (the parser works compiling this if - then - else - if - then - else... like a unique single statement, leaving to the stack the task to manage the entire code-jumping. The mistery of StackOverflow is now solved...

...
com.sun.tools.javac.parser.JavacParser.parseSimpleStatement(JavacParser.java:2519)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatement(JavacParser.java:2431)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatements(JavacParser.java:2370)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2340)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2354)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.parseSimpleStatement(JavacParser.java:2511)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatement(JavacParser.java:2431)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.parseStatementAsBlock(JavacParser.java:2395)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.parseSimpleStatement(JavacParser.java:2519)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatement(JavacParser.java:2431)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.blockStatements(JavacParser.java:2370)
at jdk.compiler/com.sun.tools.javac.parser.JavacParser.block(JavacParser.java:2340)


@Erel, don't know if you can put some arrangement / warning during the basic2java interpretation or if you want to investigate anymore, but if someone try to nest a lot of "Else If" the error is "Stack Overflow" during compilation, so it's very difficult to discover why for the poor programmer.

Thank you however for your support for this fantastic program, I hope with this post to aid someone in future having similar problems.
And sorry for my "spaghetti" English, as usual.

Maurizio
 
Last edited:
Upvote 0
Top