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.
 

Star-Dust

Expert
Licensed User
Longtime User
B4J consumes me 45.000Kb. I have noticed that using Try Catch, every error it raises goes to eat up the memory, and gradually slows down and sometimes misses the IF comparisons.

I've tried to get rid of the error handling with Try Catch and everything works fine. I don't know if this is your problem, I hope I have been helpful
 
Upvote 0

MegatenFreak

Active Member
Licensed User
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?

It happens even without opening the designer window, though that window might add further to the RAM consumption increase.
And even when I close the project and everything, and B4J is empty, the RAM consumption doesn't go down at all.

B4J consumes me 45.000Kb. I have noticed that using Try Catch, every error it raises goes to eat up the memory, and gradually slows down and sometimes misses the IF comparisons.

I've tried to get rid of the error handling with Try Catch and everything works fine. I don't know if this is your problem, I hope I have been helpful

I do use Try/Catch in several places in my code, but my problem exists even before running the app, so I don't think that's the issue.
 
Upvote 0

MegatenFreak

Active Member
Licensed User
A little update to perhaps provide a clue as to the cause. If the problem is memory leak, it should persist, right? Because the leaked memory won't just release itself automatically.
Today I noticed that if I leave B4J idle for a while, the RAM consumption begins to drop down until it's back to below 300MB. Then I start using it and it goes up again. So, if I'm not mistaken, it's not a memory leak since it drops after being idle for a while.
Then what could it be? Any ideas anyone?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The only .NET scenario that I know of that fits this is when you are using .NET objects, like images, that are a small managed overlay to very large native objects like bitmaps. The .NET garbage collector only sees the small managed part and not the large large native part so doesn't know that memory pressure is building. I wonder if the IDE might be saving the rendered image of each code module when you switch to another one and you do have 70 modules. Perhaps you could try loading the project and without editing any code just switch from module to module and see whats happens to the memory use.
 
Upvote 0

MegatenFreak

Active Member
Licensed User
That looks like the .NET garbage collector at work to me. How much total memory do you have, and how much is free when you start B4J?
I've got a total of 8 GB RAM, and around 5 GB free when I start B4J. When I load my large project, B4J is at around 280 MB, slowly building up, sometimes to 1.3 GB, but going down if I'm doing something else for a while but leaving B4J open.

The only .NET scenario that I know of that fits this is when you are using .NET objects, like images, that are a small managed overlay to very large native objects like bitmaps. The .NET garbage collector only sees the small managed part and not the large large native part so doesn't know that memory pressure is building. I wonder if the IDE might be saving the rendered image of each code module when you switch to another one and you do have 70 modules. Perhaps you could try loading the project and without editing any code just switch from module to module and see whats happens to the memory use.
I did that. There was no rise in RAM consumption when I opened around 30 modules, still no change when I switched between them, and again no change when I scrolled down in several of them, BUT THEN, I press SPACE once, it goes up by a 100, and higher as I keep doing that to different parts of the code.
Thanks for the help. Two points might help shed light on matters:
1. I noticed the same unreasonable RAM thing happening in B4A as well, with a very small 3-module project.
2. A THEORY: Is it possible it would have something to do with the intellisense system? When I pressed space bar, I turned a valid line of code to one containing errors (underlined with red), and RAM consumption jumped, then I pressed BACKSPACE and removed the error, and it jumps again. I noticed there is also a lot of CPU activity when that system kicks in. Any way I can turn that intelligent error detector off to see if there is any change?
 
Upvote 0
Top