Merge pull request #153 from NoblesseOblige/master

Address an OOM in the controller config, Free up memory
This commit is contained in:
TwistedUmbrella 2014-01-25 06:43:47 -08:00
commit 53a4862fac
3 changed files with 9 additions and 0 deletions

View File

@ -15,6 +15,7 @@
<application
android:hardwareAccelerated="true"
android:largeHeap="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

View File

@ -209,6 +209,9 @@ class GL2JNIView extends GLSurfaceView
this.editVjoyMode = editVjoyMode;
setKeepScreenOn(true);
vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
Runtime.getRuntime().freeMemory();
System.gc();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
touchVibrationEnabled = prefs.getBoolean("touch_vibration_enabled", true);

View File

@ -56,6 +56,9 @@ public class InputModFragment extends Fragment {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
parentActivity = getActivity();
Runtime.getRuntime().freeMemory();
System.gc();
mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity);
@ -348,6 +351,7 @@ public class InputModFragment extends Fragment {
}
private Drawable getButtonImage(int x, int y) {
System.gc();
try {
InputStream bitmap = parentActivity.getAssets().open("buttons.png");
BitmapFactory.Options options = new BitmapFactory.Options();
@ -355,6 +359,7 @@ public class InputModFragment extends Fragment {
Bitmap image = BitmapFactory.decodeStream(bitmap, null, options);
bitmap.close();
bitmap = null;
System.gc();
Matrix matrix = new Matrix();
matrix.postScale(32, 32);
Bitmap resizedBitmap = Bitmap.createBitmap(image, x, y, 64 / sS,