alphacep / vosk-server

WebSocket, gRPC and WebRTC speech recognition server based on Vosk and Kaldi libraries
Apache License 2.0
896 stars 243 forks source link

Memory usage increasing too much? #149

Open nefastosaturo opened 2 years ago

nefastosaturo commented 2 years ago

Hello,

pointing at issue #711 on vosk-api repo , I'm trying to understand a little bit more how vosk manages the memory.

For this test I modified a little bit and very roughly asr_server.py so that it creates a new recognizer on a new websocket connection.

I'm using the italian model at 16kHz with Docker on my laptop with 16GB RAM, i7 7700HQ laptop.

Steps to reproduce:

What expected:

memory to be released on each websocket disconnection

What we got:

memory continue to increase

From the graph image attached the first disconnection release some memory, then it just goes up.

Is this behaviour correct? Screenshot from 2021-10-20 14-57-35

nshmyrev commented 2 years ago

Hi

Your repo misses asr_server_memprof.py I suppose, but I don't think there is a point in running it at all.

In general, the point is that Python never frees memory, you won't be able to see memory release in the way you are doing it:

https://stackoverflow.com/questions/15455048/releasing-memory-in-python

You can use valgrind/massif if you want to debug memory operations probably or some other memory profiler.

nshmyrev commented 2 years ago

See also https://stackoverflow.com/questions/55294985/does-malloc-reserve-more-space-while-allocating-memory