guardianproject / ChatSecureAndroid

This project has ended, but ChatSecure iOS continues. For Android, please use Conversations or Zom instead
https://chatsecure.org/blog/chatsecure-conversations-zom/
Apache License 2.0
1.07k stars 522 forks source link

Performance improvement suggestion #434

Open 00conan00 opened 10 years ago

00conan00 commented 10 years ago

Dear developers,

I am a big fan of chat secure, and recently I am writing a static code analysis tool to conduct performance analysis for Android apps. I found several violations of "resource leakage" patterns in chat secure's code. These violations could affect the performance of your app. Here is a representative one.

In info.guardianproject.otr.app.im.app.ChatView$DataAdapter$1, the method handleMessage() invokes "new MediaPlayer();" to create MediaPlayer. However, according to the suggestion of android developer, when done with the MediaPlayer, it is a good practice to call release(), to free the resources. If not released, too many MediaPlayer instances may result in an exception. Unfortunately, this principle is not correctly applied in this method.

So I am curious :) Looking forward to your response. Thanks.

References: resource leakage pattern: http://developer.android.com/reference/android/media/MediaPlayer.html

ghost commented 10 years ago

@00conan00 It were really helpful if you could provide a pull request with a path.