Methods to reduce the CPU Usage for painting the image

Hi,
I have developed an application to view images from an IP camera. By this I can simualtaneously view images from about 25 cameras. The problem is that the CPU Usage increases as the no of player increases. My Player is JPanel. which continuously paints the images from camera. The method 'paintImage' is called from another thread's run method. This thread is responsible for taking jpeg images from IP camera.
Here is the code for this.
public void paintImage(Image image, int fps) {
try {
  int width = this.getWidth();
  addToBuffer(image);
  currentImage = image;
  Graphics graphics = this.getGraphics();
  if (isRunning && graphics != null) {
   graphics.drawImage(image, 0, 0, getWidth(), getHeight(), this);
   if(border ==true){
    graphics.setColor(Color.RED);
                      graphics.drawRect(0,0,getWidth()-1, getHeight()-1);
   graphics.setColor(Color.white);
   graphics.setFont(new Font("verdana", Font.ITALIC, 12));
   graphics.drawString("FPS : " + fps, width-60, 13);
   this.fps = fps;
   if (isRandomRecord) {
    graphics.setColor(new Color(0, 255, 0));
    graphics.fillArc((getWidth() - 10), 5, 10, 10, 0, 360);
} catch (Exception e) {
  e.printStackTrace();
Can someone please help me to solve this problem so that the CPU usage can be reduced.

Can you give me more detail information about how to use
an automated profiling tool You run it and excercise your app. Then it presents stats on number of times each method was called and time spent in each method, plus other stuff. Using those two stats you can zero in on the areas that are most likely to yield resullts.

Similar Messages

  • How could i get the kernel and user cpu usage for each process

    Hi all,
    In order to monitor the system CPU usage, I would like write a script to gather the kernel and user CPU usage for each process, like the prstat or top does. As always missing the shortlived kernel usage, prstat or top cann't get the precise CPU usage. I checked with the dtrace syscall, proc and fbt provider, but don't get which one is useful.
    Please provide your comments and suggestion.
    Thanks in adv

    mail2sleepy wrote:
    As I've studied the "dtrace" for a while, and seems Sun gives a pretty high score on this new feature.....I do want to know whether there's some probe can work for it, like writing a "dtrace" version prstat.You can write a prstat without dtrace. Because that's just polling at specific intervals and reading some process structures from /proc. You could have dtrace fire a probe every 5 seconds and read the same thing, but it wouldn't really be using any features of dtrace. Trhying to write it "in dtrace" doesn't make much sense.
    What you could do that would be harder via other methods is to fire a probe at process exit that displayed the process information including total CPU time. They could print exactly when processes exited. Doing that without dtrace would be very difficult.
    Darren

  • MBP 2.16 occasional 52% CPU usage for user account

    Every few days, my MacBook Pro, 2.16, 4 GB Ram, will run very hot at 70 degrees Celsius. Activity Monitor show high user CPU usage, usually at about 52%. I quit all non-essential services without being able to reduce user CPU usage at all. Bare minimum startup apps. A reboot always brings usage down to normal, as well as the temperature. For the life of me, I can't figure this out. This has been going on for over a year, and none of the OS updates have changed the situation. Any ideas? What am I missing?

    First, 70º C isn't all that hot. Normal range of temperatures is 30-85ºC depending upon usage. Second, total processor usage is meaningless. You need to determine what process is demanding the CPU to determine what is causing the problem if indeed there is a problem.
    Open Activity Monitor, select All Processes from the Processes drop down menu. Click twice on the CPU column heading to display in descending order. Look for the process that is consuming so much CPU time. That is the process or application that is having a problem unless it's an mds or mdworker process that may be using time because it's indexing or doing other Spotlight related work. In this case it may go on for a while but eventually it will return to normal activity.

  • How do I tap into "CPU" usage for a FP indicator

    I have built a realy effective database cruncher...With exeptionally easy graphing functionality. The problem is the opperators will not let the dbase read / filter before they start doing the elevator button thing. I currently have the clocks set to use aprox 60~75% CPU during the read and/or filter. How do I tap into the pc cpu usage for an indicator. I think it will lower there pain if they can see that the pc is working hard.
    Message Edited by MHarrington on 04-30-2007 10:12 PM

    Open your example finder and look for the example "SimpleTaskMonitor.vi". (search for .NET)
    LabVIEW Champion . Do more with less code and in less time .

  • HP Load Runner: CPU usage for this load generator has exceeded 80%

    Recently I have downloaded LR 12.1 and installed.   Observed error  CPU usage for this load generator has exceeded 80% when executing the test with 5 user load using AJAX Trulcient IE script. For each virtual user in the script one TcWebIELauncher.exe hads been initiated and running during the test execution. Each TcWebIELauncher.exe instance is taking min 14% CPU utilization and CPU utilization for 5 users is around 75% at the time of test execution.  What is the reason behind this high CPU utilization for this less user load?. Please suggest how to handle and fix the issue.
    regards,
    Sreekanth

    You can download Trail version of Loadrunner from HP site.  That's true. all HP testing tools products are license based.
    i) If you want to use for SAP applications, you need to have SAP protocals (SAP GUI and SAP WEB). So how this licenses works is, if you want to buy 50 Vusers for SAP it cost you around $ 32k and it depends on company discount. so you need to work with HP Sales team to get the quotation then based on no of Vusers and you can procure it.
    ii) As for as i know, there is no  HP LR integration with Solution Manager.
    let me know if you have any questions.

  • Sar CPU usage for each processor

    In Linux, mpstat allows you to specify a specific processor or all processors when getting CPU % usage. In OS X, sar looks pretty limited as I can only get CPU usage for all processors. I'm trying determine how many cores are in use (basically for figuring out how many single cores are available for jobs if im submitting 1 handbrake job per core)

    hello,
    I sugget to create a time series chart with the following SQL:
    with p as (select target_guid,property_value cpucount from mgmt$target_properties where property_name='CPUCount' and property_type='INSTANCE')
    select h.target_name,
    h.rollup_timestamp,
    h.average/p.cpucount pct_cpu
    from mgmt$metric_hourly h,p
    where h.metric_name='instance_efficiency'
    and h.metric_column='cpuusage_ps' and h.target_guid in (select target_guid from mgmt$db_dbninstanceinfo where target_type='oracle_database' and host=??EMIP_BIND_TARGET_GUID?? )
    and h.rollup_timestamp between ??EMIP_BIND_START_DATE?? and ??EMIP_BIND_END_DATE??
    and p.target_guid=h.target_guid
    order by 1,2
    You have to select the host target in the report and period is customizable.
    I hope this is correct and answers your question.
    Regards,
    Noel

  • High CPU usage for webservd

    we are seeing a very high CPU usage for webservd. looking at the java stack it seems to be threads communicating to sun one LDAP server.
    Anyone experienced this? is there a know issue in Java LDAP SDK?
    Sun ONE Web Server 6.1SP4 B12/16/2004
    17393 root 3741M 1655M cpu0 10 0 59:30:33 8.8% webservd/6235
    17393 root 3741M 1655M cpu16 10 0 223:58:38 8.7% webservd/5043
    17393 root 3741M 1655M cpu17 10 0 545:54:49 8.7% webservd/2902
    17393 root 3741M 1655M run 10 0 379:07:26 8.3% webservd/3996
    17393 root 3741M 1655M cpu1 30 0 213:54:52 8.3% webservd/5115
    17393 root 3741M 1655M run 20 0 56:03:44 8.2% webservd/6265
    17393 root 3741M 1655M cpu18 30 0 556:18:29 8.2% webservd/2830
    17393 root 3741M 1655M cpu3 30 0 548:09:11 8.2% webservd/2890
    17393 root 3741M 1655M run 20 0 328:18:42 8.1% webservd/4359
    17393 root 3741M 1655M cpu2 30 0 5:11:16 8.1% webservd/6722
    17393 root 3741M 1655M run 20 0 181:49:48 8.1% webservd/5322
    17393 root 3741M 1655M run 20 0 251:44:35 7.8% webservd/4857
    [02/Aug/2006:15:06:16] warning (17393): CORE3283: stderr: "BlockedThread" daemon prio=1
    0 tid=0x01110650 nid=0xb56 runnable [0x1714f000..0x1714fc10]
    [02/Aug/2006:15:06:16] warning (17393): CORE3283: stderr: at netscape.ldap.LDAPSe
    archListener.nextMessage(LDAPSearchListener.java:86)
    [02/Aug/2006:15:06:16] warning (17393): CORE3283: stderr: at netscape.ldap.LDAPSe
    archListener.getResponse(LDAPSearchListener.java:77)
    [02/Aug/2006:15:06:16] warning (17393): CORE3283: stderr: at com.iplanet.services
    .ldap.event.BlockedThread.run(BlockedThread.java:121)
    [02/Aug/2006:15:06:16] warning (17393): CORE3283: stderr: at java.lang.Thread.run
    (Thread.java:595)

    forgot to mention: OS is solaris 9

  • Do I need to reduce the images size in pixels before upload them to M.Me?

    Do I need to reduce the images size in pixels (actual size jpeg 5616 × 3744 pixels/766kb) before upload them from iPhoto to a Mobile Me Gallery?
    Otherwise they will be heavy or the upload process take care of that?
    It would be nice that iPhoto took care and optimize the images to display online without any more work, because I´ve 1200 images to upload and they´re jpegs 5616 × 3744 pixels. It´s just to viewing purposes. Not o download or print.
    Thanks.

    In fact no matter if I use a High or Medium compression size JPEG, the size after upload is the same.
    Starts with 1,5 MB/5600px (high) or 780kb/5600px (medium) JPEG and ends after upload in 115kb for a 1024px image.
    This means that iPhoto auto compress in order to publish to Mobile Me, even if we start with a bigger file.
    I hope this info is useful to others.
    Thanks.

  • Can anyone help me to add method to rotate the image using mouse?

    Hi everyone, i am currently creating a game which require the user to be able to drag and rotate the image
    on the screen..but sadly...i'm only able to do the dragging part..
    Can anyone be able to help me add the method to rotate the image using the mouse?
    Thanks :-)
    the code
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    class Game extends JFrame {
         DisplayCanvas canvas;
         public Game() {
              super("My Game");
              Container container = getContentPane();
              canvas = new DisplayCanvas();
              TitledBorder border = new TitledBorder("Game Window");
              border.setTitlePosition(TitledBorder.BOTTOM);
              canvas.setBorder(border);
              container.add(canvas);
              addWindowListener(new WindowEventHandler());
              setSize(450,400);
              show();
              class WindowEventHandler extends WindowAdapter {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              public static void main(String arg[]) {
                   new Example();
         class DisplayCanvas extends JPanel {
              int x, y;
              BufferedImage bi;
              DisplayCanvas() {
                   setBackground(Color.white);
                   setSize(450,400);
                   addMouseMotionListener(new MouseMotionHandler());
                   Image image = getToolkit().getImage("duke.gif");
                   MediaTracker mt = new MediaTracker(this);
                   mt.addImage(image, 1);
                   try {
                        mt.waitForAll();
                   catch (Exception e) {
                        System.out.println("Exception while loading image.");
                   if (image.getWidth(this) == -1) {
                        System.out.println("***Make sure you have the image "
                        + "(duke.gif) file in the same directory.*****");
                        System.exit(0);
                   bi = new BufferedImage(image.getWidth(this),
                   image.getHeight(this),
                   BufferedImage.TYPE_INT_ARGB);
                   Graphics2D big =bi.createGraphics();
                   big.drawImage(image, 0, 0, this);
              public void paintComponent(Graphics g) {
                   super.paintComponent(g);
                   Graphics2D g2D = (Graphics2D) g;
                   g2D.drawImage(bi, x, y, this);
              class MouseMotionHandler extends MouseMotionAdapter {
                   public void mouseDragged(MouseEvent e) {
                        x = e.getX(); y = e.getY();
                        repaint();

    research a bit on AffineTransforms. you can set the rotated instance of the Graphics2D class and it will do the rotations for you :-D

  • Scanning: The image size is too big. Please reduce the image height, width, resolution, scaling or output type.

    Good Day.
    I have recently discovered an issue with scanning.  I have tried scanning straight from the printer, through image capture, and through preview.  All yeilding the same results since they are essentailly kicking off the same scanning applet.  I can scan a jpeg formatted file as long as I applet is in the "Hide Details" mode.  If I click on the "Show Details" button, which I need to do to scan to PDF, I immediately receive an error stating: The image size is too big. Please reduce the image height, width, resolution, scaling or output type.
    I'm currently using an HP C5180 printer.   The most recently installed software was Adobe Digital Editions (I installed this to read an on-line e-book).  Not sure if there is any correlation.    Thanks for any help.
    Mac details are:
      Model Name:          MacBook Pro
      Model Identifier:          MacBookPro8,1
      Processor Name:          Intel Core i5
      Processor Speed:          2.3 GHz
      Number of Processors:          1
      Total Number of Cores:          2
      L2 Cache (per Core):          256 KB
      L3 Cache:          3 MB
      Memory:          8 GB
      Boot ROM Version:          MBP81.0047.B27
    Printer access log:
      Source:          /var/log/cups/access_log
      Size:          174 bytes
      Last Modified:          11/21/12 10:09 PM
      Recent Contents:          localhost - - [21/Nov/2012:22:09:16 -0500] "POST / HTTP/1.1" 200 61628 CUPS-Get-PPDs -
    localhost - - [21/Nov/2012:22:09:20 -0500] "POST / HTTP/1.1" 200 61628 CUPS-Get-PPDs -
    Image Capture Support:
      Image Capture Support:
      Path:          /Library/Image Capture/Support/Hewlett-Packard/Devices/HPAiOScan.bundle/Contents/Info.plist
      Version:          2.3.0
      Path:          /Library/Image Capture/Support/Hewlett-Packard/Devices/HPAiOScan.bundle/Contents/Resources/Dev iceInfo.plist
      Version:          2.3.0
    Photosmart C5100 series:
      Status:          Idle
      Print Server:          Local
      Driver Version:          4.0.0
      Default:          Yes
      Shared:          No
      URI:          dnssd://Photosmart%20C5100%20series%20%5B960B9E%5D._pdl-datastream._tcp.lo cal./?bidi
      PPD:          HP Photosmart C5100 series
      PPD File Version:          4.0.0
      PostScript Version:          (3011.104) 0
      CUPS Version:          1.6svn (cups-327)
      Scanning support:          Yes
      Scanning app (bundleID path):          -
      Scanning app version:          -
      Scanner UUID:          CC8DD435-CC8D-D435-CC8D-D435CC8DD435
      Printer Commands:          ReportLevels
      CUPS filters:
    Inkjet:
      Path:          /Library/Printers/hp/cups/Inkjet.driver/Contents/MacOS/Inkjet
      Permissions:          rwxr-xr-x
      Version:          4.0.0
    commandtohp:
      Path:          /Library/Printers/hp/cups/filters/commandtohp.filter/Contents/MacOS/comman dtohp
      Permissions:          rwxr-xr-x
      Version:          2.1.1
      Fax support:          No
      Printer utility:          /Library/Printers/hp/Utilities/HP Utility.app
      Printer utility version:          5.9.1
      PDEs:
    PDE.plugin:
      Sandbox compliant:          Yes

    Hello Sig
    The scanner works with a Windows computer, which proves the device is functional at a cursory level. The drivers are now distributed by Apple and this is an Apple computer. There is no scanning software provided by HP. HP's answer is that Mountain Lion takes care of all of this.  I anticipate that some setting or driver was somehow tweaked since the scanner had been working with Mountain Lion until a few days ago.  The device in question is an Apple product. So, I'm pretty confident that I'm in the right place.
    Regards

  • Email-to facilitate emailing a photo by gmail or AOL, I reduce the file size.  Is it better to reduce the image size or increase the jpg compression?

    To facilitate emailing a photo by gmail or AOL and avoid overwhelming the recipient's screen, I reduce the file size.  Is it better to reduce the image size or increase the jpg compression?  I have been making a duplicate image of 35 MB and reducing the image size to 8"x12" at 72 resolution giving a file size of 1.4 MB.  Then I SAVE AS a jpg of medium compression giving a  file size of about 111 KB.  Overkill?

    Go to File>save for web.
    I usually make the long side 800 px
    At the bottom of the dialog, check "constrain proportions."
    At the top, select JPEG in the dropdown for the file format.
    All the work is done for you! 72px/in is ok for web work. 240-300px/in is the recommended range for printing.

  • How do I change the background colour to the viewing screen when I reduce the image below full size

    Currently the screen has a black border when I scroll to reduce the image size. Originally it may have beeen white. I may have altered the setting but I dont know what. Any suggestions please.
    The programme is Elements 8

    Right click on the screen, then select custom color.

  • I notice that Foxfire 4 sometimes shows 50 to 60% CPU usage for no apparent reason. If I reboot, its back to normal for a few hours. Then the same problem recurrs and I have to reboot again. I have just upgraded to 4.0.1. Don't know if it helps

    At the same time, I often see ccsvchst.exe using 30 to 50% CPU to really slow everything down. I checked this with Norton; and they uninstall/reinstalled Norton - three times. I still see this program with excessive CPU usage sometimes. If I reboot, sometimes it helps. Other times, not.

    When you have kernel panics, the pertinent information is in the panic report.
    These instructions must be carried out as an administrator. If you have only one user account, you are the administrator.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    In the Console window, select
              DIAGNOSTIC AND USAGE INFORMATION ▹ System Diagnostic Reports
    (not Diagnostic and Usage Messages) from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar.
    There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of reports. A panic report has a name that begins with "Kernel" and ends in ".panic". Select the most recent one. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
    If you don't see any reports listed, but you know there was a panic, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
    In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
    Please don’t post other kinds of diagnostic report.
    I know the report is long, maybe several hundred lines. Please post all of it anyway.

  • High CPU usage for SERVER0 process in XI

    Hi,
    SERVER0 process is taking high CPU usage, previously it happen once its due to communication channel error, So we deativated some unwanted communication channels in Alert config and the CPU usage is reduced.
    After some weeks its again CPU usage is increasing for SERVER0 process in some time.
    Can anyone help in this case.
    Thank you,
    gopi.

    Hi Gopi,
    Check out Tim's reply and check for ur Java stack settings,
    Extended Memory parameters
    <i>The bottom line for J stacks is to keep everything in memory and out of swap. </i>
    Other tips:
    - u may try clearing folder usr\sap\<SID>\DVEBMGS00\j2ee\cluster\server0\apps
    - try increasing virtual memory
    - increase heap size
    <i>[Reward if helpful]</i>
    Regards,
    Prateek

  • Question about CPU usage for video playback

    I've asked a related question already on the Safari forum, but would like some clarification, please.
    The speed of this iMac is 400 MHZ and whenever I go to YouTube or almost any other site that requires video I see that the CPU usage can peak way up at 80% or more. I have Flash 9 installed which has a minimum of 500 MHZ, so I get pretty choppy video, but that's not the issue here. I can live with that. I keep any other applications closed. I'm often running a small fan over the top of the iMac to help vent the buildup of heat. I can monitor the temperature at the Hard Drive and I suppose that gives me an idea, of sorts, about general temperature conditions inside.
    The answer I got was that this kind of CPU usage could be detrimental to the processor as it builds up excessive heat and to keep this kind of video to a minimum.
    My question is can anyone roughly suggest what a maximum time on YouTube, for example, would be, 2 minutes, 5 minutes, is 10 minutes too long? I have plenty of RAM at 768. Some guidelines?
    Thanks.

    Hey WZZZ,
    Thanks for the star and kind words.
    I'm the de facto Mac guy at my kids' school and we have around 25 iMac Slot Loaders working there. You can imagine they get abused quite a bit. There are 10 running Garage Band in the Music Department. That puts a tremendous strain on the CPU and I'm actually surprised that they run it so well. My son had a 600 iMac running GarageBand, he was complaining that it was getting jumpy and when I looked at it he was running 10 unlocked tracks simultaneously! So now he has an eMac G4 800 and that of course runs a lot better.
    So to sum up, with all the abuse of those machines in terms of the CPUs the problems I have with them have nothing to do with that. The problems have more to do with parts of the OS that they toss, headphone jacks abused, CDs jammed in the slots, and the like.
    A couple of other related things. I've got Hardware Monitor, demo, installed and I think it reported it could only find the hard drive sensor, if I'm not mistaken - nothing else on this Mac with a sensor. Is that right?
    I see references to CPU sensors on 400 iMacs but on the 400 I have here for repair Temperature Monitor reports no sensors. Perhaps there were different versions of the 400.
    But very good to hear that the fan is a good idea for CRT related things. Should I keep the fan running-mostly for that hard core CRT stuff- even if the computer is sleeping and the room temp. is only around 62-64 F.? (We need to put on warm clothes to sit in front of this thing now, but worth it to keep this old machine happy).
    On the one I did the fan pushed the airflow in the direction of the passive flow of the iMac - in at the bottom and out the grill by the handle.
    One more question, more out of curiosity than anything else: If I move this small clip-on fan close to the case - right now it's about 3 feet away and the image is stable - the screen begins to flicker and flutter quite a lot. My theory is that that's happening not necessarily because of electro-magnetic interference from the fan motor, but rather, because the back of the tube is getting cooled unevenly. What do you think?
    Well the classic failures that I see in the iMac are in this order:
    1) Dielectric breakdown of the flyback transformers internal insulation. This is heat/age related and a common problem with CRTs in general.
    2) Breakdown of high voltage electolytic capacitors and regular high voltage capacitors on the neck board and PAV supply.
    3) Solder problems with the flyback itself. This is diagnosed by the upside down boot technique.
    I used to repair these problems but now it's easier for me to swap the Firewire boards into working 350s. I've got 12 of those in the basement currently.
    Richard

Maybe you are looking for

  • FAT 32 & PORTABLE STORAGE DEVICES.

    HI i'm looking to buy a portable storage device (psd) for my digital camera - one where i can slot in the memory card & save my photos on it while im away. Amazingly, there are problems with these devices not being able to be formatted on macs "becau

  • Sync problem with iPod Touch

    I downloaded episode #1 of a tv show to my iTouch. Then I purchased the season of the same show, and downloaded it to my imac. This download included Episode #1 again. My iTunes folder correctly shows Episode #1 only once. However, when I sync my iTo

  • Best way to prepare for SJCP 1.4

    Hello All, I'm planning on taking the SJCP 1.4 exam and was wanting some current feedback on preparation on the exam. I have a couple of books and the Whizlabs exam software. How much time should I expect to put in to prepare and is the Whizlabs soft

  • Smartform output uneven....

    hi all, i m having couple of issues if  u can help me out.. 1. i have defined a table and then line type for one internal table i need to display. I have assigned the texts to the columns and then the fields. problem is output i receive is not in str

  • Solaris 10 in desktop computer?

    Hi everybody, How are u? I am Palash. I want to install Solaris 10 in my desktop computer. Is it possible? And would anyone give me a link for book/document on Sun Certified System Admin Guide Part-1(Solaris 10)? Thanks in advance for co-operation