GVKun编程网logo

如何分析.hprof文件?(如何分析hprof文件)

28

对于想了解如何分析.hprof文件?的读者,本文将是一篇不可错过的文章,我们将详细介绍如何分析hprof文件,并且为您提供关于$在.hprof文件AndroidStudio中是什么意思、android

对于想了解如何分析.hprof文件?的读者,本文将是一篇不可错过的文章,我们将详细介绍如何分析hprof文件,并且为您提供关于$在.hprof文件Android Studio中是什么意思、android – 处理hprof文件时出现意外错误:null、android – 错误打开HPROF文件:IOException:未知的HPROF版本、android-studio – 错误:期待HPROF文件格式1.0.3的有价值信息。

本文目录一览:

如何分析.hprof文件?(如何分析hprof文件)

如何分析.hprof文件?(如何分析hprof文件)

我的生产服务器运行时带有以下标志: -XX:+ HeapDumpOnOutOfMemoryError

昨晚,当我们的服务器遇到堆错误时,它生成了一个java-38942.hprof文件。事实证明,系统开发人员知道该标志,但无法从中获取任何有用的信息。

有任何想法吗?

答案1

小编典典

如果您想要一个相当高级的工具来认真研究一下,请查看Eclipse 的Memory
Analyzer项目,该项目由SAP贡献。

您可以做的一些事情非常适合发现内存泄漏等-包括对内存对象运行受限SQL(OQL)形式,即

从com.yourcompany.somepackage.User中选择toString(firstName)

完全辉煌。

$在.hprof文件Android Studio中是什么意思

$在.hprof文件Android Studio中是什么意思

初始化Gc并单击android studio监视器中的转储Java堆后,将出现以下图像:

enter image description here

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.尽量避免使用静态字段.

android – 处理hprof文件时出现意外错误:null

android – 处理hprof文件时出现意外错误:null

在特定设备上存在大量的内存问题,其中大量内存被分配到无处不在.我试图做一个heapdump来找出分配内存是什么,但是当我尝试打开heapdump文件时,我在 Android Studio中收到一个错误:

HprofView – 处理hprof文件时出现意外错误:null

我已经做了一些网页搜索,但是没有任何对这个错误的引用,据我所知.我只需要帮助获取堆转储,我可以从那里修复我的应用程序.

编辑:我尝试转换转储文件,但它给了我另一个错误:

转换Android Java堆转储 – 转储堆转储时出现意外错误:错误:读取16710959的33177623字节

解决方法

我不能给出一个明确的答案,但根据我的经验,似乎在应用程序接近其内存使用限制时发生.当您尝试调试OutOfMemoryError时,显然不是很理想!

有两件我可以建议解决的问题:

>尝试使用不同的设备/模拟器.例如我发现这个问题在我的三星S5上是很常见的,但是在我的Nexus 4上却不太常见.>暂停应用程序一段时间后,内存不足,然后在那时获取堆转储.这不是理想的,但内存泄漏往往会导致一段时间内的问题,而是一次性出现问题,所以您仍然可以诊断泄漏.

android – 错误打开HPROF文件:IOException:未知的HPROF版本

android – 错误打开HPROF文件:IOException:未知的HPROF版本

尝试使用Memory Analyzer打开HPROF文件(由Debug.dumPHProfData创建)时,我收到以下异常:

java.io.IOException: UnkNown HPROF Version (JAVA PROFILE 1.0.3)
at org.eclipse.mat.hprof.AbstractParser.readVersion(AbstractParser.java:124)
at org.eclipse.mat.hprof.Pass1Parser.read(Pass1Parser.java:69)
at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:65)
at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:203)
at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:114)
at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:143)
at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:123)
at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:56)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

我该如何解决这个问题?

解决方法:

您从Android获得的hprof文件具有特定于Android的格式.您应该将Android操作系统中的hprof文件转换为标准的hprof格式.为此,您可以使用位于AndroidSDK / tools / hprof-conv的hprof-conv工具.

例如:

hprof-conv android.hprof mat.hprof

然后在Memory Analyzer中打开mat.hprof.

编辑:hprof-conv可能位于AndroidSDK / platform-tools /下的某些包中.

android-studio – 错误:期待HPROF文件格式1.0.3

android-studio – 错误:期待HPROF文件格式1.0.3

我将堆转储导出为HPROF,并根据 docs使用.hprof后缀保存它.当我运行hprof-conv命令时,发生错误:

ERROR: expecting HPROF file format 1.0.3

结果我获得了0大小的converted-heap.hprof文件. Eclipse Memory Analyzer无法打开它.

附加信息:

>有类似的问题here,但仍然没有解决转换错误.
>如果重要,我使用新的Android Studio 3和Android Profiler来导出堆转储.

enter image description here

解决方法

1.这个hprof.file必须单击Dump Java Heap save file.(检查你保存.hprof文件) 2.当您单击Allocation Traking时,保存hprof.file.will会抛出此错误.

关于如何分析.hprof文件?如何分析hprof文件的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于$在.hprof文件Android Studio中是什么意思、android – 处理hprof文件时出现意外错误:null、android – 错误打开HPROF文件:IOException:未知的HPROF版本、android-studio – 错误:期待HPROF文件格式1.0.3的相关知识,请在本站寻找。

本文标签: