Problem in CPU usage

Hi all,

I have C++ program that is running on linux on an ARM processor. The program is sending voice to a specific ip. When i started the program, 2 threads are running and sending voice over ip. Each of the threads are at %0.2 CPU usage which is very normal. My problem is, CPU usage is increasing hour by hour. After 10 hours it becomes %45 CPU usage for each of the threads which is very high. Because of this, the voice in both threads slows down, too. If i close both threads, and start new ones without closing the program, they start from beginning at %0.2 CPU usage. Why could it be? Where should i look?

Thanks.
Gokay

Maybe more threads are openning in the runtime?

Only a guess, but given that it grows over time it could be that you have some kind of list or array-like entity that is growing without reasonable bound, and it is simply taking more CPU cycles to process the growing amount of data. It could be worthwhile to see if memory usage is also growing over time.

Sounds like a memory leakage thing, basically more news than deletes.

Or lists growing and not havings items removed.

With the information provided I think the best you're going to get are guesses. Might be worth taking a look at a good logging utility like log4c. You have the ability to pass all sorts of objects like arrays and vectors to it and it will display the contents of them giving you an easy overview of if their contents is growing. Adding some lines of debug code at various points in your code is another obvious solution.

You mention CPU usage increasing. Does memory usage also increase too? If so think about implimenting a Memory Printer class that peridocially prints the used/available memory.

Another thought, and one I've come across quite a bit within my own company, is your program talking to some sort of database? Is it performing read and writes to a specific table that is getting bigger and bigger. If you have a thread that is querying a table at a given interval then obviously the more rows in the table you have the poorer the performance of your application will become, well without proper indexing anyway.