High CPU affecting memory usage.

Hi , I have an application which consumes 100% CPU (kinda CPU hogger which performs non blocking read continuously without sleep) .In addition , i run some of my applications which communicate on local IPC ,tcp etc.
I had observed that before starting CPU hogger there are no leaks in my applications.
As soon as i start CPU hogger after sometime ,my applications start consuming/leaking memory continuously.
I have been able to reproduce this problem everytime.Before starting CPU hogger ,everything is neat and clean.Once it starts ,some of my applications incrementally start consuming memory until no memory left.(I have 256 mb ram and once all processes start i am left with 100 mb).

Any idea why this is happening?

Without knowing a lot more about your applications, the CPU hogger and the priority they all run at, I would say the most likely cause is that your applications are being starved for CPU time. So they are queuing up some data/message responses etc in an ever growing linked list/list class etc.

If everything is running at the same priority you might just want to run your hogging process at 1 lower so that it can still hog but your other apps get CPU time whenever they need it.

Tim

Thanks Tim for reply.
Ya you are right .My observations are valid when the CPU hogger and my applications run at same priority.If my run my hogger at a lower priority i dont seem to get this behaviour.But what seems to confuse me is that evrytime i run this test case ,i get a different application leaking memory.Could it be the case that it is dependent on scenario a particular application is running at that time?
Also i have aps scheduler running .If i run the cpu hogger in different partiton than where my applications are running ,it doesnt affect my applications.Only when it is run at same priority and same partition do i get these problems.One more observation ,some of threads of my applications are always in READY state.

How do you know which application is leaking memory?

That is by definition what Adaptive Scheduling is supposed to do. No surprises there.

How are you determining they are always in the ready state?

What is it you are trying to do/accomplish here? You already know that something in your apps keeps using memory if you have a process using 100% of the CPU (BTW, I consider a leak to be allocating memory and forgetting to free it. Continually adding something to a list but not having CPU time to process the list and free it is a problem but is not what I consider a memory leak). But is that actually a big deal or something likely to happen in your system?

Tim

I have a script running which logs memeory usage and thread states of all my applications using showmem and pidin commands.

Problem is if i leave my system running in this state ultimately entire memory gets eaten up and system hangs/reboots and does all sort of weird behaviour.
Maybe as u have said it coud be possible that one of the high priority threads may be continuously queueing data without the other thread dequeing it.
Is it that sysyetm will always exhibit this behaviour if i run into a scenario wherein someone continuously hogs CPU without releasing it?
Maybe i should prevent this situation from happening but if it does ever happen my only concern was system may not be able to recover.

You have possible solutions for this:
a) use Adaptive Partitioning
b) use different priorities
c) use sporadic scheduling on the CPU hogger? - kinda something between a and b.

I also assume that you know that a process taking 100% for a longer time is bad design.

Normally you can run a thread at a high priority, consuming all CPU for a long time, without having memory issues. So it must be some of your other processes that are starved of CPU time that are causing this. Does any of them receive timer-based pulses? These queue up. If you don’t give the pulse receiver time to process the pulses, an out-of-memory issue is the expected result.

So what is the question? How to react to the out-of-memory issue? The processes with the queued up pulses (assuming this is the problem) can’t do anything about this. Your CPU hogging process possibly is trying to allocate memory but doesn’t get any. The return value of malloc() should be checked in this case.

So have you got the solution to stop this leaking memory and how you have done this?

achat maison neuve