B4J Question B4J Consuming 1.3GB Ram and slowing down

MegatenFreak

Active Member
Licensed User
Hi. When I run B4J, everything is fine for a while, but after a while it starts slowing down (for example, doing some things in code only takes effect after a few seconds) and B4J's RAM consumption exceeds 1.3 GB. I have to quit and reopen it which is very annoying.
I searched the forums and noticed something called "optimized dexer" mentioned, along with how to turn it off in B4A.
Now, I don't have a problem with RAM consumption. I have a lot of it. But the slow-down is unbearable. What should I do?
Thanks a lot in advance.
 

jahswant

Well-Known Member
Licensed User
Longtime User
Hi. When I run B4J, everything is fine for a while, but after a while it starts slowing down (for example, doing some things in code only takes effect after a few seconds) and B4J's RAM consumption exceeds 1.3 GB.
I had this issue. The best solution is to Augment you RAM total. This is beacause B4J launches JAVA and JAVA consumes many RAM.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is beacause B4J launches JAVA and JAVA consumes many RAM.
That's not correct.
B4J doesn't launch Java and generally speaking, Java doesn't consume a lot of RAM.

The optimized dexer is a B4A only tool. It is not related to B4J.

I'm working on a relatively large project now (Pleroma client). B4J takes less than 200MB here (64 GB is installed on this computer).
 
Upvote 0

MegatenFreak

Active Member
Licensed User
Are you working on a very large project? Does it happen with all projects?
The project is rather large, but I don't know if it's too large. I've got around 70 code modules, each dealing with separate pages with different functions in the app, but the large number (70+) is only to avoid mixing up the code. There's roughly an average of 1000 lines of code in each module. And there are around 90 layout files. Could this size be the issue? (I mean, why would it need 1GB of ram?) The ram consumption begins at around 230MB and gradually increases, like it's caching something onto the ram.
I don't work on any other projects currently, but I don't think the issue would persist in small projects, maybe.

did you try to switch off "Auto Backup"?
Yes, I've turned it off.
 
Upvote 0

MegatenFreak

Active Member
Licensed User
UPDATE:
Today when my RAM consumption went up and B4J slowed down, I decided to keep on working with it, though everything, even auto complete took seconds to function. Eventually, while trying to compile the app, the compiler gave a JAVA OUT OF MEMORY EXCEPTION and soon after that B4J crashed.
This is no doubt because something is piling up in the memory without being cleaned.
Is it possible that garbage collection isn't working properly??
 
Upvote 0

MegatenFreak

Active Member
Licensed User
That's quite a similar case. I downloaded the tool and dumped B4J's memory, but it's too complex. I have no idea where to look...
Anyway, I decided to go step by step, so I opened my project and left it idle for a while, no increase. Than I start to add a single line of code, and RAM consumption increases up to 100MB... I compile, it goes higher. Every time I repeat that process, a little bit gets added. Once I close and reopen B4J, all's back to normal.
Literally, every time I press ENTER to add a new line to the code, RAM consumption goes up by about 20 MB...
I'm so confused... :(
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
btw, does B4J have a 64-bit version??
It is not related. As I wrote, there are no known memory leaks and the IDE can usually run for weeks without restarting.

You can upload the heap file into Dropbox or similar service and I'll see if I can extract anything meaningful.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I have a sw that I developed with b4j which makes my pc struggle a lot but the problem is not b4j, it is not my sw, it is Javac.

My sw at runtime:
1603113869159.png


B4J with a project open:
1603113896945.png
 
Upvote 0

MegatenFreak

Active Member
Licensed User
Is that just compile, or compile and run? I'm just wondering if your project itself has a memory leak, if that's possible in B4J.
It happens even without any compilation. Just as long as B4J is open and I'm working, the RAM consumption gradually increases. I'll test that again to make sure it is the case. Which means it has nothing to do with the Java compiler, and since Erel says B4J has no memory leaks itself, it is definitely true. That's what makes it so confusing. The things is, I had the same problem on my old laptop with Windows 8.1.

It is not related. As I wrote, there are no known memory leaks and the IDE can usually run for weeks without restarting.
You can upload the heap file into Dropbox or similar service and I'll see if I can extract anything meaningful.
Thanks. But my upload is brutally slow. Instead, if you could just point out (if it isn't too much trouble) where I should look (since that memory analysis app has so many parts such as string analysis, arrays, etc. etc.) and whether I should dump only the virtual memory or everything, I'd be able to take a closer look.
 
Upvote 0

MegatenFreak

Active Member
Licensed User
Sorry for posting again, but something new happened today and I thought it might shed light on matters.
Today when I opened task manager, B4J RAM consumption was at 800MB, nothing strange, BUT there was ALSO a "Java SE Platform binary (WYSIWIG)" (or something very similar) with around 1.2GB RAM consumption! As soon as I closed the WYSIWYG window of B4J designer, that process disappeared along with its 1+ GB RAM consumption.
I was wondering if that might be a clue as to what the heck is going on in my OS... Does this prove that the root of the problem lies in Java itself?
Also, does the B4J code editor itself depend on Java? I was thinking maybe fully uninstalling Java JDK and JRE and reinstalling would help.
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
As soon as I closed the WYSIWYG window of B4J designer, that process disappeared
Do you keep the Designer window open all the time? Does the incremental RAM use that you mentioned above on Enter still exhibit without the Designer open? If you unload the big project after adding lots of lines does the RAM use return to what it was before the program was opened?

Also, does the B4J code editor itself depend on Java?
No, it's a .NET Framework program using WPF for the UI.

I was thinking maybe fully uninstalling Java JDK and JRE and reinstalling would help
Unlikely - but any port in a storm. It's quick and uncomplicated to try anyway.
 
Upvote 0
Top