jeudi 3 mars 2016

OutofMemory crash "failed to allocated byte allocation with free bytes

03-03 13:37:43.229 133-133/? E/[EGL-ERROR]: egl_image* _egl_create_image_ANDROID_native_buffer(egl_display*, egl_context*, EGLClientBuffer, EGLint*, void*):593: CHUN try create image with crop 0,0,0,0
03-03 13:37:43.553 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 447(20KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 4MB/4MB, paused 25.913ms total 87.278ms
03-03 13:37:43.656 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 46.371ms
03-03 13:37:43.726 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 936(110KB) AllocSpace objects, 0(0B) LOS objects, 36% free, 6MB/10MB, paused 49.983ms total 169.228ms
03-03 13:37:44.172 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 12MB/12MB, paused 115.409ms total 371.940ms
03-03 13:37:44.708 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 12.347ms
03-03 13:37:44.716 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 14(448B) AllocSpace objects, 0(0B) LOS objects, 19% free, 17MB/21MB, paused 157.012ms total 529.711ms
03-03 13:37:44.966 154-154/? D/AudioMTKHardware: +setParameters(): rotation=90 
03-03 13:37:44.966 154-154/? D/AudioMTKHardware: +setCommonParameters(): rotation=90 
03-03 13:37:44.966 154-154/? D/AudioMTKHardware: Remove key rotation from pair rotation=90
03-03 13:37:44.967 154-154/? D/AudioMTKHardware: -setCommonParameters(): rotation=90 
03-03 13:37:44.967 154-154/? E/audio_a2dp_hw: adev_set_parameters: ERROR: set param called even when stream out is null
03-03 13:37:45.486 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 360.502ms
03-03 13:37:45.496 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 4(128B) AllocSpace objects, 0(0B) LOS objects, 0% free, 22MB/22MB, paused 215.163ms total 697.293ms
03-03 13:37:46.297 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 666.999ms
03-03 13:37:46.307 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 10(320B) AllocSpace objects, 0(0B) LOS objects, 15% free, 22MB/26MB, paused 216.105ms total 790.569ms
03-03 13:37:46.671 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 37.559ms
03-03 13:37:47.295 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 8(256B) AllocSpace objects, 0(0B) LOS objects, 0% free, 28MB/28MB, paused 281.801ms total 881.029ms
03-03 13:37:48.333 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 693.489ms
03-03 13:37:48.350 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 14(448B) AllocSpace objects, 0(0B) LOS objects, 12% free, 28MB/32MB, paused 280.007ms total 1.040s
03-03 13:37:48.797 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 445.971ms
03-03 13:37:48.811 18779-18794/edu.byu.cs.superasteroids W/art: Suspending all threads took: 460.896ms
03-03 13:37:48.824 18779-18779/edu.byu.cs.superasteroids D/AndroidRuntime: Shutting down VM
03-03 13:37:49.374 456-521/? E/WifiStateMachine: stopReconnectWifi Wfd=false StopScan=false mDontReconnectAndScan=false
03-03 13:37:50.037 1170-1170/? I/wpa_supplicant: wlan0: CTRL-EVENT-SCAN-RESULTS 
03-03 13:37:50.868 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 1.714s
03-03 13:37:51.046 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 139.310ms
03-03 13:37:51.122 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 38.308ms
03-03 13:37:51.160 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 4947(178KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/95MB, paused 2.320ms total 2.261s
03-03 13:37:51.160 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 596.300ms for cause Alloc
03-03 13:37:51.372 133-206/? I/hwcomposer: [DPY] UEventThread::threadLoop recv change@/devices/platform/battery/power_supply/battery
03-03 13:37:51.611 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 742407(26MB) AllocSpace objects, 0(0B) LOS objects, 5% free, 69MB/73MB, paused 1.030ms total 336.375ms
03-03 13:37:51.611 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 332.947ms for cause Alloc
03-03 13:37:51.706 18779-18794/edu.byu.cs.superasteroids W/art: Suspending all threads took: 93.970ms
03-03 13:37:51.894 18779-18794/edu.byu.cs.superasteroids I/art: Background sticky concurrent mark sweep GC freed 18810(2MB) AllocSpace objects, 9(1698KB) LOS objects, 0% free, 77MB/77MB, paused 1.393ms total 133.657ms
03-03 13:37:52.143 456-667/? I/ActivityManager: Killing 18668:http://ift.tt/1Y6RyvB (adj 12): empty #13
03-03 13:37:52.176 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 73610(8MB) AllocSpace objects, 4(5MB) LOS objects, 4% free, 81MB/85MB, paused 1.165ms total 252.249ms
03-03 13:37:52.176 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 55.036ms for cause Alloc
03-03 13:37:52.176 18779-18789/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 17.252ms for cause Alloc
03-03 13:37:52.513 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 47138(5MB) AllocSpace objects, 3(6MB) LOS objects, 4% free, 81MB/85MB, paused 886us total 220.420ms
03-03 13:37:52.514 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 116.996ms for cause Alloc
03-03 13:37:52.804 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 145.094ms
03-03 13:37:52.847 18779-18794/edu.byu.cs.superasteroids I/art: Background partial concurrent mark sweep GC freed 30235(3MB) AllocSpace objects, 1(6MB) LOS objects, 4% free, 85MB/89MB, paused 1.190ms total 255.264ms
03-03 13:37:52.972 18779-18779/edu.byu.cs.superasteroids I/art: WaitForGcToComplete blocked for 16.783ms for cause Alloc
03-03 13:37:53.009 18779-18779/edu.byu.cs.superasteroids I/art: Alloc sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 2% free, 84MB/86MB, paused 1.120ms total 8.917ms
03-03 13:37:53.254 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 93.605ms
03-03 13:37:53.282 18779-18779/edu.byu.cs.superasteroids I/art: Alloc partial concurrent mark sweep GC freed 17(912B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.108ms total 218.701ms
03-03 13:37:53.527 18779-18779/edu.byu.cs.superasteroids I/art: Alloc concurrent mark sweep GC freed 13(12KB) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.015ms total 216.641ms
03-03 13:37:53.554 18779-18779/edu.byu.cs.superasteroids I/art: Forcing collection of SoftReferences for 14MB allocation
03-03 13:37:53.770 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 105.509ms
03-03 13:37:53.797 18779-18779/edu.byu.cs.superasteroids I/art: Alloc concurrent mark sweep GC freed 11(344B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.051ms total 216.460ms
03-03 13:37:53.824 18779-18779/edu.byu.cs.superasteroids E/art: Throwing OutOfMemoryError "Failed to allocate a 15587580 byte allocation with 4194304 free bytes and 11MB until OOM"
03-03 13:37:53.834 18779-18779/edu.byu.cs.superasteroids I/art: Alloc sticky concurrent mark sweep GC freed 5(448B) AllocSpace objects, 0(0B) LOS objects, 2% free, 84MB/86MB, paused 1.066ms total 8.626ms
03-03 13:37:54.078 18779-18779/edu.byu.cs.superasteroids I/art: Alloc partial concurrent mark sweep GC freed 10(320B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.130ms total 215.957ms
03-03 13:37:54.320 18779-18789/edu.byu.cs.superasteroids W/art: Suspending all threads took: 151.859ms
03-03 13:37:54.347 18779-18779/edu.byu.cs.superasteroids I/art: Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 1.031ms total 214.426ms
03-03 13:37:54.374 18779-18779/edu.byu.cs.superasteroids I/art: Forcing collection of SoftReferences for 14MB allocation
03-03 13:37:54.589 18779-18779/edu.byu.cs.superasteroids I/art: Alloc concurrent mark sweep GC freed 7(224B) AllocSpace objects, 0(0B) LOS objects, 4% free, 84MB/88MB, paused 894us total 214.533ms
03-03 13:37:55.554 18779-18779/edu.byu.cs.superasteroids E/art: Throwing OutOfMemoryError "Failed to allocate a 15587580 byte allocation with 4194304 free bytes and 11MB until OOM"
03-03 13:37:55.611 18779-18779/edu.byu.cs.superasteroids E/AndroidRuntime: Error reporting crash, early in start. Won't generate crash log file.
                                                                           java.lang.OutOfMemoryError: Failed to allocate a 15587580 byte allocation with 4194304 free bytes and 11MB until OOM
                                                                               at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
                                                                               at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:125)
                                                                               at java.lang.StringBuffer.append(StringBuffer.java:278)
                                                                               at java.io.StringWriter.write(StringWriter.java:123)
                                                                               at com.android.internal.util.FastPrintWriter.flushLocked(FastPrintWriter.java:358)
                                                                               at com.android.internal.util.FastPrintWriter.appendLocked(FastPrintWriter.java:303)
                                                                               at com.android.internal.util.FastPrintWriter.write(FastPrintWriter.java:625)
                                                                               at com.android.internal.util.FastPrintWriter.append(FastPrintWriter.java:658)
                                                                               at java.io.PrintWriter.append(PrintWriter.java:691)
                                                                               at java.io.PrintWriter.append(PrintWriter.java:31)
                                                                               at java.lang.Throwable.printStackTrace(Throwable.java:323)
                                                                               at java.lang.Throwable.printStackTrace(Throwable.java:300)
                                                                               at android.util.Log.getStackTraceString(Log.java:340)
                                                                               at com.android.internal.os.RuntimeInit.Clog_e(RuntimeInit.java:59)
                                                                               at com.android.internal.os.RuntimeInit.access$200(RuntimeInit.java:43)
                                                                               at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:85)
                                                                               at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                                                                               at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)

I'm not sure what is going my memory screen seems to be jumping up to about 100 MBs I'm not sure if that's quite a bit or if that's pretty normal. Either way any help at all would be great.

    package edu.byu.cs.superasteroids.main_menu;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import edu.byu.cs.superasteroids.R;
import edu.byu.cs.superasteroids.base.ActionBarActivityView;
import edu.byu.cs.superasteroids.content.ContentManager;
import edu.byu.cs.superasteroids.database.DBhelper;
import edu.byu.cs.superasteroids.game.GameActivity;
import edu.byu.cs.superasteroids.importer.ImportActivity;
import edu.byu.cs.superasteroids.ship_builder.ShipBuildingActivity;

public class MainActivity extends ActionBarActivityView implements IMainMenuView {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }

    //TODO: Set this activity's controller to an instance of your MainMenuController
    //TODO: Pass the MainMenuController's constructor a reference to its IMainMenuView (this)
    //IMainMenuController controller = new MainMenuController(this);
    //setController(controller);


    //TODO: Initialize your database

    DBhelper.init(getBaseContext());

    ContentManager.getInstance().setResources(getResources());
    ContentManager.getInstance().setAssets(getAssets());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container, false);
        return rootView;
    }
}

public void startGame(View v) {
    Intent intent = new Intent(this, ShipBuildingActivity.class);
    startActivity(intent);
}

public void quickPlay(View v) {
    if (getController() != null) {
        ((IMainMenuController) getController()).onQuickPlayPressed();
    }
}

public void startGame() {
    Intent intent = new Intent(this, GameActivity.class);
    intent.setFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP);
    this.startActivity(intent);
}

public void importData(View v) {
    Intent intent = new Intent(this, ImportActivity.class);
    startActivity(intent);
}


@Override
public void onDestroy() {
    super.onDestroy();
}

}

and

package edu.byu.cs.superasteroids.importer;

import android.content.res.AssetManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import edu.byu.cs.superasteroids.R;

public class ImportActivity extends ActionBarActivity {

private ListView listView;
private Resources res;
private AssetManager am;
private List<String> fileList;
private IGameDataImporter dataImporter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_import);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }

    //TODO: Set the dataimporter to an instance of your GameDataImporter
    dataImporter = new GameDataImporter(this);

}


@Override
public void onResume() {

    super.onResume();

    res = getResources();
    am = res.getAssets();

    String[] files = null;
    try {
        files = am.list("");
    } catch (IOException e) {
        e.printStackTrace();
    }

    fileList = null;
    if(files != null) {
        fileList = new ArrayList<String>();
        for(String file : files) {
            if(file.endsWith(".json"))
                fileList.add(file);
        }
        if(fileList.size() > 0) {
            ImportFileAdapter fileAdapter = new ImportFileAdapter(this,
                    android.R.layout.simple_list_item_1, fileList);
            ListView listView = (ListView) findViewById(R.id.import_list);
            listView.setAdapter(fileAdapter);
            listView.setOnItemClickListener(fileClickListener);
            fileAdapter.notifyDataSetChanged();
        }
    }

}

private AdapterView.OnItemClickListener fileClickListener = new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

        Toast toast = Toast.makeText(ImportActivity.this, "", Toast.LENGTH_LONG);
        if(dataImporter == null) {
            toast.setText("The importer has not been implemented or created yet...\nThe file was not imported.");
        }
        else {
            try {

                boolean success = dataImporter.importData(new InputStreamReader(
                        new BufferedInputStream(am.open(fileList.get(i)))));

                if (success)
                    toast.setText("The file was imported.");
                else
                    toast.setText("An error occurred as the importer tried to import the file.");

            } catch (IOException e) {
                e.printStackTrace();
                toast.setText("The file could not be imported, because it does not exist.");
            }
        }
        toast.show();
    }
};

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_import, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_import, container, false);
        return rootView;
    }
}

}

Although I'm not sure that this is actually where it's crashing, I say this because these portions of code were working just fine now sometimes just to open the app requires a large amount of data and it doesn't seem to be working.

Aucun commentaire:

Enregistrer un commentaire