[API Review]: RT-28817 - Add explicit dispose() method to MediaPlayer

Florian Brunner fbrunnerlist at gmx.ch
Mon Mar 11 15:23:17 PDT 2013


Consider to implement AutoCloseable instead, which would it make compatible with the new Automatic Resource Management, if needed.

http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html

http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html

-Florian

Am Mittwoch, 6. März 2013, 15.07:16 schrieb Alexander Matveev:
> Hi all,
> 
> Explicit dispose() method is needed to free native resources used by 
> MediaPlayer. Garbage collector is not reliable enough to free native 
> resources fast enough, thus when MediaPlayers are created fast enough we 
> may run out of native memory. Normally, user does not need to call 
> dispose() method on MediaPlayer if application does not create them 
> often. After dispose() is called MediaPlayer cannot be used again and 
> should be disregarded. Media and MediaView associated with disposed 
> MediaPlayer can be reused. Dispose() will be valid in any states. For 
> example, when player is playing call to dispose() will stop playback and 
> release all resources.
> 
> JIRA:
> http://javafx-jira.kenai.com/browse/RT-28817
> 
> Thanks,
> Alexander


More information about the openjfx-dev mailing list