初始化Gc并单击android studio监视器中的转储Java堆后,将出现以下图像:
DialogFrag $1之类的DialogFrag类旁边的$是什么意思? (DialogFrag只是扩展Dialogfragment的类)
我应该只有一个此类的实例,但是正如您可以在DialogFrag $1旁边看到的那样,总数为7,这是否意味着我有内存泄漏?
编辑:这是我的对话框片段类
public class DialogFrag extends DialogFragment { AsyncTask<VoID,VoID,VoID> asyncTask; @OverrIDe public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alertdialog=new AlertDialog.Builder(getActivity()); alertdialog.setTitle("Solution:"); VIEw vIEw = getActivity().getLayoutInflater().inflate(R.layout.dialogfrag,null); final MyVIEw myvIEw= (MyVIEw) vIEw.findVIEwByID(R.ID.myvIEw); myvIEw.setVisibility(VIEw.INVISIBLE); alertdialog.setVIEw(vIEw); asyncTask=new AsyncTask<VoID, VoID, VoID>() { @OverrIDe protected voID doInBackground(VoID... voIDs) { //compute something here } @OverrIDe protected voID onPostExecute(VoID param) { super.onPostExecute(param); getDialog().findVIEwByID(R.ID.progress).setVisibility(VIEw.GONE); myvIEw.setVisibility(VIEw.VISIBLE); } }); asyncTask.execute(); alertdialog.setPositivebutton("SHOW", new DialogInterface.OnClickListener() { @OverrIDe public voID onClick(DialogInterface dialogInterface, int i) { if(!(asyncTask.getStatus()== AsyncTask.Status.FINISHED)){ asyncTask.cancel(true); } asyncTask=null; dismiss(); } }); alertdialog.setNegativebutton("Cancel", new DialogInterface.OnClickListener() { @OverrIDe public voID onClick(DialogInterface dialogInterface, int i) { if(!(asyncTask.getStatus()== AsyncTask.Status.FINISHED)){ asyncTask.cancel(true); } asyncTask=null; dismiss(); } }); Dialog dialog=alertdialog.create(); dialog.getwindow().getAttributes().windowAnimations = R.style.MyDialogVIEwAnimation; return dialog; } @OverrIDe public VIEw onCreateVIEw(LayoutInflater inflater, VIEwGroup container, Bundle savedInstanceState) { getDialog().getwindow().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.top); getDialog().requestwindowFeature(Window.FEATURE_NO_Title); return super.onCreateVIEw(inflater, container, savedInstanceState); }
解决方法:
what does the $next to the class DialogFrag like in DialogFrag$1 means ?
$number表示匿名内部类,例如new.VIEw.OnClickListener(){…}.
but as you can see next to DialogFrag$1 the total count is 7 , does this mean i have memory leak?
也许,您将手机旋转了七次吗?
请记住以适当的生命周期方法取消注册侦听器和broadcastReceivers.尽量避免使用静态字段.
总结以上是内存溢出为你收集整理的$在.hprof文件Android Studio中是什么意思全部内容,希望文章能够帮你解决$在.hprof文件Android Studio中是什么意思所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)