Strange thread behaviour after starting more than four threads

mbed OS 6.15.1

I tried to create a project which would recieve/send data over 2 USARTS (one of which is connected to ST-LINK for USB communication and the second one is connected to HC-05 module) and process incoming data in some way.

I wrote code for communication with only one USART, which uses three threads (recieving data, processing data, and sending data back) and it works fine, but when i add more threads (i tried adding one for recieving from second USART and one for sending through it) any thread that is started after the first four either never does anything, or (when i tried adding idle loop that prints every 5 seconds) works but some threads that were started earlier stop working correctly. What could be causing this?

From what i can gather it happens because there is not enough RAM for all threads to run, but it never raises any errors so i’m not sure. Is there any way to check memory usage in debugger?

Link to the repository with code: GitHub - YryRybkin/mbed-test-connection