B4J Question How to search a slow "bottle neck" ?

peacemaker

Expert
Licensed User
Longtime User
Hi, All

I'm debugging the app that dynamically scan COM-ports under Windows, connect to all free ones and wait for a data flow of MCU equipment.
So, each COM-port is connected by a class. And actually only one COM-port is active under test recently.

I.e. when a new COM-port is found, connected - collecting the traffic is stared, to a buffer, checking the start\stop markers and parsing the data.
COM-ports speed is fixed just of 9600 baud.
App is B4Xpage-based, 4 pages, main and second (and 2 rarely used utility topmost windows).

But when parsing is started - the app memory consumption is rised from 160 MB to 300+ and freezing beginning.
AsyncStreams should work in non-main thread, as i remember, speed is .... not big, data records frequency into SQLite db is 1....10 records per second only.
If to stop parsing - memory is not freed, but freezing is ended after some seconds only, not immediately flow is ended.

During this freezing the device disconnecting is processed by the app only after the port buffer is empty, or cannot be processed, and port is blocked until replugging and killing the app.
How to debug where the "bottle neck" is ?
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Extra info: such freezing is only if to use some MCU boards with Arduino sketches (as data source for COM-port). If i try to emulate this by a ESP8266 board (with B4R sketch) that generates a similar data flow - no any freezing at even max speed !

Sure, Release mode is much more better (than the debug mode with only the main thread) but after some time is anyway started to freeze.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Ha ! I have found that the huge memory leak was due to .... the internal log based on CustomListView :)
That was growing unlimitedly.
And the slowest operation - it was saving into SQLite db: it's freezing if to try to save each data record parsed from the COM-port flow. Passing by part of data by the time helped.
 
Upvote 0
Top