Just now i was interviewed by ca(Computer Associates) for a C++ opening.
Q:There is an application that continuously runs for days.. at som开发者_运维技巧e day it becomes non-responsive/gets hanged.How would you Debug/rectify the application.What will be your first steps?
A:I answered starting with .. having a check on memory usage details/CPU usage..checking if some of the required resources are available...or if it is network bound,if the network is live..etc..
Q:He told.. these are all superficial things.. assume no such problem is there..then?
A:I told the best way is to check the debug logs if they are enabled..and if they arent..give the customer a debug enabled application and test it in the field. Because the application is hanging intermittently..its very difficult to detect through any other way why it would go unresponsive..And debug logs would tell me at what instant the application starts to go mad,as to find the root cause the specific operation responsible needs to be known,and debug logs are what i think the best bet.
The interviewer switched to another question says .. ok fine.
So,was my answer good enough.Any other approach that a good programmer would follow?
Use WinDbg or create a (mini) dump file and load it up in your Visual Studio. Load debugging symbols for all the release binaries, and see exactly where it is hung
That should be a decent first step
Edit Of course I was (foolishly) assuming windows for no apparent reason. On UNIX/linux this would be even easier using strace
, ptrace
, gdb --remote
, pstack
, dtrace
(if it's there) etc
Edit Also using WMI performance counters/perfmon is a very good practice in general. This would perhaps shed some light (but I'm sure the interviewer was looking for the 'How do I inspect a running application' type of answer; this is slightly leaning to the 'depend on logging' approach that you already had mentioned in your own answer)
Most of the times such questions cannot be answered to the point because they are very much subjective. They are usually asked to evaluate & judge how a potential candidate approaches a problem and shows some constructive approach of debugging the problem. As long as the answer shows some logical methodology of tackling the problem the answer is good.
Your answer was good. To add to it, Most important is to identify the use case/pattern where the problem occurs. If a problem is reproducble easily it is solvable. So I would try to define steps to reproduce the problem and then move ahead with steps to tackle it.
精彩评论