0

私は Android プログラミングの初心者です。2 つの Activites に 6500 行近くの膨大な量のコードを書きました。これらの Activites にアクセスする (使用する) と、完璧に動作しますが、しばらくすると動作が遅くなり、クラッシュします。 xxxxx (何らかの値) バイトのメモリを割り当てることができません。アクティビティから抜け出す (または作業を完了する) 前に、これらのアクティビティで使用したすべてのビューに null 値を初期化し、System.gc(); を呼び出しました。しかし、それでもこのエラーが発生します。これらの欠陥を回避する方法。

私のファイルで使用しているビューの数:

EditText et_af_loc;
Spinner spn_astStatus, spn_af_astName;
TableRow tr_af_newAst;
ArrayAdapter<String> adp_status, adp_reason;
Button btn_takePic, btn_save, btn_send, btn_gps;
String gpsData = "";
MyLocationListener listener = null;
LocationManager locationManager;
Location loc = null;
ImageView iv_MEPhoto;
Button btn_METakePhoto;
ProgressDialog progressBar, progDailog;
String SENDING_IMAGE_PATH = "";
Spinner spn_af_area;
String image_PATH = "", image_str, ImgString = "";
boolean photoTaken = false;
ArrayAdapter<String> adp_subCompo, adp_drainExi, adp_platExi;
ProgressDialog progServerHit;
String strResponse, sendingString;
DBHelper dbHelper;
SQLiteDatabase db;
TableRow tr_reason;
Spinner spn_reason;
Spinner spn_asstCate, spn_af_drainExist, spn_af_platFormExist,
        spn_af_cisType;
Button btn_af_Send;
ArrayAdapter<String> adp_asstCate, adp_new, adp_area, adp_cisType, adp_sub,
        adp_soFor;
EditText et_other, et_af_capi;
// String newSourId[];
EditText et_af_noOfFill;
TableRow tr_af_capacity, tr_af_noOfFills, tr_af_drainExist,
        tr_af_platExist, tr_af_capaLPM, tr_af_disCharge, tr_af_loc,
        tr_af_areaCoverage, tr_af_make, tr_af_yeildLMP, tr_af_cistern;

EditText et_af_capiLmp, et_af_disCharge, et_af_make, et_af_yeildLMP;

TableRow tr_af_sub, tr_af_MiSsTankCapi, tr_af_soFor;
Spinner spn_af_sourSubType, spn_af_soFor;
TableRow tr_af_sourHeading;
LinearLayout ll_af_sourL, ll_af_sourR;
ArrayList<String> allChkBox;

TableRow tr_af_diaOfBwell, tr_af_deptOfBoreWell, tr_af_noOfGIpipes,
        tr_af_drainCondition, tr_af_watQualPara, tr_af_dtComOfStr,
        tr_af_pumpSetCap, tr_af_pmpSetDesi, tr_af_pmpSetDesHead,
        tr_af_pmpingHrs, tr_af_InfiWellDia, tr_af_InfiWellDepth,
        tr_af_InfiGalLenDia, tr_af_InfiGalLoc, tr_af_InTakStrDiame,
        tr_af_InTakStrDepth, tr_af_OtClWatQualPar, tr_af_IntSumpCap;

EditText et_af_MiSsTankCapi, et_af_diaOfBorewell, et_af_deptOfBwell,
        et_af_noOfGIpipes, et_af_wQualPara, et_af_dtOfComStr,
        et_af_pumpSetCap, et_af_pumpSetDes, et_af_pumpSetDesHead,
        et_af_pumpHrs, et_af_InfiWellDia, et_af_InfiWellDepth,
        et_af_InfiGalLenDia, et_af_InfiGalLoc, et_af_InTakStrDiame,
        et_af_InTakStrDepth, et_af_OtClWatQualPar, et_af_IntSumpCap;
Spinner spn_af_drainCondi;
String sourFrmToFlag;
TextView tv_af_gpsLati, tv_af_gpsLongi;
int count = 0;
String newACCount, newSCCount;
String newAssetCode, newSourceCode, district_id, sourAstID;
String HAB_ID;

TableRow tr_tacassCode_pc, tr_tacassCode_dd, tr_tacassCode_ph,
        tr_tacassCode_dh;
EditText et_tac_psCapInHP, et_tac_psDesDisch, et_tac_psDesHead,
        et_tac_psPumpingHrs;
CheckBox cb_ps;
Spinner spn_tac_subMer;
ArrayAdapter<String> adp_subMer = null, adp_goodBad;
TableRow tr_af_rsFil, tr_af_ssFil, tr_af_clorniation, tr_af_ariea,
        tr_af_miFil, tr_af_claFil, tr_tacassCode_subMer;
String psAvi = "NA", uid;
CheckBox cb_af_rsFil, cb_af_ssFil, cb_af_clori, cb_af_ariea, cb_af_miFil,
        cb_af_claFic;
String cbRsFill = "", cbSsFill = "", cbClori = "", cbAriea = "",
        cbmiFill = "", cbClafi = "";
String otherMandLink = "NA";
EditText et_af_REMARKS;

String ASSET_CODE_GEN, SOURCE_CODE_GEN;
String mandalID;
String panchID, todayDate;

Spinner spn_af_linking;
ArrayAdapter<String> adp_linking;

TableRow tr_af_linking, tr_tacassCode_ssOW, tr_tacassCode_ssHp,
        tr_tacassCode_ssSubSurAss;

// openwell
RadioGroup rg_owIsThereLat10mOfWell, rg_owIsTheLatHighGrThanWell,
        rg_owIsTherSouOfPollWithin10mOfWell,
        rg_IsTherDrainPoorCausStWat2mOfWell, rg_owIsTherFaultDrainChannel,
        rg_owIsTherAdeqParapet, rg_owIsThereCemeFloorLesThan1m,
        rg_owAreWallOfWellInadwqSealed, rg_owAreTherAnyCraksOnCemFloor,
        rg_owAreTheRopeAndBucket, rg_owIsTheWelCovered;

RadioButton rg_owIsThereLat10mOfWell1, rg_owIsTheLatHighGrThanWell1,
        rg_owIsTherSouOfPollWithin10mOfWell1,
        rg_IsTherDrainPoorCausStWat2mOfWell1,
        rg_owIsTherFaultDrainChannel1, rg_owIsTherAdeqParapet1,
        rg_owIsThereCemeFloorLesThan1m1, rg_owAreWallOfWellInadwqSealed1,
        rg_owAreTherAnyCraksOnCemFloor1, rg_owAreTheRopeAndBucket1,
        rg_owIsTheWelCovered1, rg_owIsThereLat10mOfWell2,
        rg_owIsTheLatHighGrThanWell2, rg_owIsTherSouOfPollWithin10mOfWell2,
        rg_IsTherDrainPoorCausStWat2mOfWell2,
        rg_owIsTherFaultDrainChannel2, rg_owIsTherAdeqParapet2,
        rg_owIsThereCemeFloorLesThan1m2, rg_owAreWallOfWellInadwqSealed2,
        rg_owAreTherAnyCraksOnCemFloor2, rg_owAreTheRopeAndBucket2,
        rg_owIsTheWelCovered2;

String owIsThereLat10mOfWell = "NA", owIsTheLatHighGrThanWell = "NA",
        owIsTherSouOfPollWithin10mOfWell = "NA",
        IsTherDrainPoorCausStWat2mOfWell = "NA",
        owIsTherFaultDrainChannel = "NA", owIsTherAdeqParapet = "NA",
        owIsThereCemeFloorLesThan1m = "NA",
        owAreWallOfWellInadwqSealed = "NA",
        owAreTherAnyCraksOnCemFloor = "NA", owAreTheRopeAndBucket = "NA",
        owIsTheWelCovered = "NA";

// handPump
RadioGroup rg_hpIsThereLat10m_mtsOfHP, rg_hpIsTheNeaLatOnHiGr,
        rg_hpIsTheAnyOthSou, rg_hpIsTheDrainPooSta,
        rg_hpIsTheHpDraiChanFaulty, rg_hpIsTheCemFlorles,
        rg_hpIsTherAnyPondingOnCem, rg_hpIsTherAnyCrackOnCem,
        rg_tac_hpIsABuckUsed, rg_hpIsTheHpLooseAtPt,
        rg_hpIsTheCoverOfWelInsani, rg_hpAreTheWalOfWellInadeSea;

RadioButton rg_hpIsThereLat10m_mtsOfHP1, rg_hpIsTheNeaLatOnHiGr1,
        rg_hpIsTheAnyOthSou1, rg_hpIsTheDrainPooSta1,
        rg_hpIsTheHpDraiChanFaulty1, rg_hpIsTheCemFlorles1,
        rg_hpIsTherAnyPondingOnCem1, rg_hpIsTherAnyCrackOnCem1,
        rg_tac_hpIsABuckUsed1, rg_hpIsTheHpLooseAtPt1,
        rg_hpIsTheCoverOfWelInsani1, rg_hpAreTheWalOfWellInadeSea1,

        rg_hpIsThereLat10m_mtsOfHP2, rg_hpIsTheNeaLatOnHiGr2,
        rg_hpIsTheAnyOthSou2, rg_hpIsTheDrainPooSta2,
        rg_hpIsTheHpDraiChanFaulty2, rg_hpIsTheCemFlorles2,
        rg_hpIsTherAnyPondingOnCem2, rg_hpIsTherAnyCrackOnCem2,
        rg_tac_hpIsABuckUsed2, rg_hpIsTheHpLooseAtPt2,
        rg_hpIsTheCoverOfWelInsani2, rg_hpAreTheWalOfWellInadeSea2;

String hpIsThereLat10m_mtsOfHP = "NA", hpIsTheNeaLatOnHiGr = "NA",
        hpIsTheAnyOthSou = "NA", hpIsTheDrainPooSta = "NA",
        hpIsTheHpDraiChanFaulty = "NA", hpIsTheCemFlorles = "NA",
        hpIsTherAnyPondingOnCem = "NA", hpIsTherAnyCrackOnCem = "NA",
        tac_hpIsABuckUsed = "NA", hpIsTheHpLooseAtPt = "NA",
        hpIsTheCoverOfWelInsani = "NA", hpAreTheWalOfWellInadeSea = "NA";

// subsurface assets

RadioGroup rg_tac_ssIsTherLat30m, rg_tac_ssIsTheNearlatUnsewe,
        rg_tac_ssIsTherAnyOthSouWit10m, rg_tac_ssIsTherAnUnCapped,
        rg_tac_ssIsTheDraiAreaPhFaulty, rg_tac_ssIsTheFencAroTheInstDamag,
        rg_tac_ssIsTheFlrOfHpPerTowat, rg_tac_ssIsTheWellSealInsani,
        rg_tac_ssIsTheChlorRecShow, rg_tac_ssIsTheFreeChlResi;

RadioButton rg_tac_ssIsTherLat30m1, rg_tac_ssIsTheNearlatUnsewe1,
        rg_tac_ssIsTherAnyOthSouWit10m1, rg_tac_ssIsTherAnUnCapped1,
        rg_tac_ssIsTheDraiAreaPhFaulty1,
        rg_tac_ssIsTheFencAroTheInstDamag1, rg_tac_ssIsTheFlrOfHpPerTowat1,
        rg_tac_ssIsTheWellSealInsani1, rg_tac_ssIsTheChlorRecShow1,
        rg_tac_ssIsTheFreeChlResi1, rg_tac_ssIsTherLat30m2,
        rg_tac_ssIsTheNearlatUnsewe2, rg_tac_ssIsTherAnyOthSouWit10m2,
        rg_tac_ssIsTherAnUnCapped2, rg_tac_ssIsTheDraiAreaPhFaulty2,
        rg_tac_ssIsTheFencAroTheInstDamag2, rg_tac_ssIsTheFlrOfHpPerTowat2,
        rg_tac_ssIsTheWellSealInsani2, rg_tac_ssIsTheChlorRecShow2,
        rg_tac_ssIsTheFreeChlResi2;

String ssIsTherLat30m = "NA", ssIsTheNearlatUnsewe = "NA",
        ssIsTherAnyOthSouWit10m = "NA", ssIsTherAnUnCapped = "NA",
        ssIsTheDraiAreaPhFaulty = "NA", ssIsTheFencAroTheInstDamag = "NA",
        ssIsTheFlrOfHpPerTowat = "NA", ssIsTheWellSealInsani = "NA",
        ssIsTheChlorRecShow = "NA", ssIsTheFreeChlResi = "NA";

CheckBox cb_tacassCode_ssOW, cb_tacassCode_ssHp, cb_tacassCode_ssSubSurAss;
LinearLayout ll_tac_owRbs, ll_tac_hpRbs, ll_tac_ssRbs;

String owSanataryExisting = "NA", hpSanataryExisting = "NA",
        ssurSanataryExisting = "NA", sanataryValues = "";

TextView tv_af_assetMarker;
TableRow tb_tacassCode_psAvi;

この後、findviewbyId(); を使用してビューを読んでいます。次に、ビジネスロジックに従って、いくつかのビューを非表示/表示し、検証に多くの文字列を使用し、EditText から値を読み取り、データを保存し、画像をキャプチャし、画像を文字列に変換する他のビューを使用しています

元:

if(editText.getText().toString().equals("")){
Toast.makeText(this,"Enter Value for xxx",5000).show();
}else if(){...... so on ...!   

最後に、操作/タスクを完了した後、すべてのビューを無効にし、bitmap=null にして System.gc(); を呼び出します。しかし、まだアプリのパフォーマンスが不足しています(応答しない、クラッシュする)。

このコードに対してまだ何ができますか?

4

1 に答える 1