This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Starting a third-part app consumes 50% CPU! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Starting a third-part app consumes 50% CPU!" Watch "Starting a third-part app consumes 50% CPU!" New topic
Author

Starting a third-part app consumes 50% CPU!

David Irwin
Ranch Hand

Joined: Mar 25, 2004
Posts: 82
All,

I have a third-party application (VLC video decoder from http://www.videolan.org) that I start using Java, specifically using the following Java code:



I hold onto the process object so that I can close VLC later on.

When I start VLC using my Java application as shown above, the VLC application consumes 50% of the CPU before even doing anything; it's not even decoding video yet! (note: VLC the application is consuming 50% of the CPU, not my Java application; this per the Windows task manager). If I start VLC just by itself it doesn't consume anything more than 1% of the CPU.

Any reason why this would be so? It's causing a real problem when I actually start decoding video because VLC then consumes nearly 100% of the CPU.

Thanks,
Dave

Java 1.5+ on Windows XP
[ June 25, 2008: Message edited by: David Irwin ]
David Irwin
Ranch Hand

Joined: Mar 25, 2004
Posts: 82
Doing a little more research I came across the ProcessBuilder class in the Java 1.5 API. When I start VLC using the process builder the CPU usage is near 1% when idle. I'm hoping that this will help solve my problem.

Dave
David Irwin
Ranch Hand

Joined: Mar 25, 2004
Posts: 82
After looking at the Java 1.5 source it turns out that the Runtime.exec() method actually uses the ProcessBuilder class. And I have been unable to get my application to start successfully using the ProcessBuilder class alone.
Since Runtime.exec() actually uses ProcessBuilder internally I don't expect any fix if I were to get the standalone ProcessBuilder approach to work.

Any ideas?

Thanks,
Dave
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38100
    
  22
You are familiar with the traps in Runtime.exed(), as described in the classic article by Daconta? Please do a search of JavaRanch; there are other threads active at present addressing similar questions.
[ June 27, 2008: Message edited by: Campbell Ritchie ]
David Irwin
Ranch Hand

Joined: Mar 25, 2004
Posts: 82
Originally posted by Campbell Ritchie:
You are familiar with the traps in Runtime.exed(), as described in the classic article by Daconta? Please do a search of JavaRanch; there are other threads active at present addressing similar questions.

[ June 27, 2008: Message edited by: Campbell Ritchie ]


Thanks for the reference...I hadn't read the article but for my sake I unfortunately was already doing much of what was suggested in the article.

Does anyone know of an alternative to using Runtime.exec(), such as some third-party library?

Thanks,
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Starting a third-part app consumes 50% CPU!
 
Similar Threads
Downloading Live Streaming Video from CNBC Awaaz
JAVA APIs to parse MP4 file
Swing: Playing Video
Multiprocessor JVM Scalability
Sharing iTunes Library without Opening iTunes