JMF massive memory leak



Hi,

i'm trying to build a simple app using tutorial based player, that would
display a couple of videos at a time in a paused state showing the first
frame of each of them.

This gives me a headache, because calling start() on a player and stop()
directly after its realisation seems to make its resources impossible to
destroy. The effect is, that after refreshing the screen 3 times with 12
thumbnails on it my program is occupying over 200 MB of memory :).

I've noticed that simple calling start(), playing and then destroying player
as it is said in all documentation works well. Perhaps there is some
timeline in which methods, garbage collector and other stuff should be
called in order to close everything properly? I've gone through every
possible newsgroup and can't find the answer.

Here is a code sample from my player class. I'd be grateful for any help on
this.

Thx.




public class VideoComponent extends JPanel implements ControllerListener {


[.........Cut..........]


// ------------------------------------------------------------------------
public void init() {
MediaLocator mrl;
URL url;
File file;

this.setOpaque(false);
this.setLayout(new BorderLayout());
this.setBackground(Color.black);
panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(new BorderLayout());
this.add(panel, BorderLayout.CENTER);

try {
file = new File(videoPath);
url = new URL("file:///" + file.getAbsolutePath());
mrl = new MediaLocator(url);

// jesli nie ma pliku wywal blad
if (mrl == null) error("No media locator");


try {
player = Manager.createPlayer(mrl);
} catch (Exception e) {
e.printStackTrace();
error(e.getMessage());
}

/* dodaj ta klase jako listener playera */
player.addControllerListener(this);

} catch (MalformedURLException e) {
error("Invalid media file URL!");
} catch (IOException e) {
error("IO exception creating player");
}

start();
}


// ------------------------------------------------------------------------
public void start() {
if (player == null) return;
player.start();
playing = true;
}


// ------------------------------------------------------------------------
public void stop() {
if (player != null) {
player.stop();
player.deallocate();

}
playing = false;
}


// ------------------------------------------------------------------------
public void pause() {
if (player != null) player.stop();
playing = false;
}


// ------------------------------------------------------------------------
public void destroy() {
if (player != null) player.close();
playing = false;
}


// ------------------------------------------------------------------------
private void removeView() {
panel.removeAll();
controlComponent.dispose();
visualComponent = null;
controlComponent = null;
}


// ------------------------------------------------------------------------
private void removePlayer() {
player.removeControllerListener ( this );
player = null;
}


// ------------------------------------------------------------------------
public synchronized void controllerUpdate(ControllerEvent event) {

[.........Cut..........]

if (event instanceof RealizeCompleteEvent) {

if (!autoPlay) pause();

[.........Cut..........]


} else if (event instanceof EndOfMediaEvent) {

if (!loop) return;
player.setMediaTime(new Time(0));
player.start();

} else if (event instanceof ControllerErrorEvent) {
stop();
destroy();
error(event.toString());
} else if (event instanceof ControllerClosedEvent) {
removeView();
removePlayer();
}

}


// ------------------------------------------------------------------------
private void error(String msg) {
System.out.println(msg);
}



}





.



Relevant Pages

  • Re: expected errors
    ... //create a CardWorker object to get the songs ... public void begin ... System.out.println("Please Enter Player Name"); ... System.out.println("The numeric values of certain cards are as ...
    (comp.lang.java.help)
  • Re: Event Based or Get-Key based
    ... want to separate my GUI logic from my game logic. ... player control code to know anything about the inventory screen (save ... public void playerAttack ...
    (rec.games.roguelike.development)
  • getting jmf to read rtsp
    ... How can I get JMF to read a rtsp stream and displaying the content in a ... I have modified the code in JMF's documentation, ... Player player = null; ... public void start{ ...
    (comp.lang.java.programmer)
  • Re: JMF Player DRIVING ME CRAZY!
    ... It should iterate over the playlist and for each track create a Player, wait for an EndOfMediaEvent, create a Player for the next track and so on. ... public void configureComplete{ ... System.out.println(" configuring"); ...
    (comp.lang.java.help)
  • Re: Fading effect
    ... Please link to your web page that has the applet. ... private void printThreadName{ ... public void init() { ...
    (comp.lang.java.help)