1<!DOCTYPE html>
2<html>
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5    <title>quickstart_native_memory</title>
6
7    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
9    <style>
10      code[class*='smartperf-'],
11      pre[class*='smartperf-'] {
12        color: #333333;
13        background: none;
14        font-family: Helvetica;
15        line-height: 1.6;
16        text-align: left;
17        white-space: pre;
18        -moz-tab-size: 9;
19        -o-tab-size: 9;
20        tab-size: 8;
21        -webkit-hyphens: none;
22        -moz-hyphens: none;
23        -ms-hyphens: none;
24        hyphens: none;
25      }
26
27      /* Code blocks */
28      pre[class*='smartperf-'] {
29        padding: 0.9em;
30        overflow: auto;
31        border-radius: 2px;
32        background: #f5f5f4;
33      }
34
35      /* Inline code */
36      :not(pre) > code[class*='smartperf-'] {
37        white-space: normal;
38        background: #fcf8f8;
39        padding: 1px 0.2em;
40        border-radius: 1px 0.3em;
41      }
42
43      .tk.comment,
44      .tk.blockquote {
45        color: #8c918c;
46      }
47
48      .tk.cdata {
49        color: #183898;
50      }
51
52      .tk.doctype,
53      .tk.punctuation,
54      .tk.variable,
55      .tk.macro.property {
56        color: #424242;
57      }
58
59      .tk.operator,
60      .tk.important,
61      .tk.keyword,
62      .tk.rule,
63      .tk.builtin {
64        color: #b71d65;
65      }
66
67      .tk.string,
68      .tk.url,
69      .tk.regex,
70      .tk.attr-value {
71        color: #16338d;
72      }
73
74      .tk.property,
75      .tk.number,
76      .tk.boolean,
77      .tk.entity,
78      .tk.atrule,
79      .tk.constant,
80      .tk.symbol,
81      .tk.command,
82      .tk.code {
83        color: #037aa2;
84      }
85
86      .tk.tag,
87      .tk.selector,
88      .tk.prolog {
89        color: #69ad62;
90      }
91
92      .tk.function,
93      .tk.namespace,
94      .tk.pseudo-element,
95      .tk.class,
96      .tk.class-name,
97      .tk.pseudo-class,
98      .tk.id,
99      .tk.url-reference .tk.variable,
100      .tk.attr-name {
101        color: #775d9d;
102      }
103
104      .tk.entity {
105        cursor: help;
106      }
107
108      .tk.title,
109      .tk.title .tk.punctuation {
110        font-weight: bold;
111        color: #1a3773;
112      }
113
114      .tk.list {
115        color: #f56940;
116      }
117
118      .tk.inserted {
119        background-color: #eaffea;
120        color: #509b2f;
121      }
122
123      .tk.deleted {
124        background-color: #fae1e1;
125        color: #ad2d06;
126      }
127
128      .tk.bold {
129        font-weight: bolder;
130      }
131
132      .tk.italic {
133        font-style: normal;
134      }
135
136      /* JSON */
137      .smartperf-json .tk.property {
138        color: #19358c;
139      }
140
141      .smartperf-markup .tk.tag .tk.punctuation {
142        color: #2c2b2b;
143      }
144
145      /* CSS */
146      code.smartperf-css,
147      .smartperf-css .tk.function {
148        color: #047ca4;
149      }
150
151      /* YAML */
152      .smartperf-yaml .tk.atrule {
153        color: #609b5a;
154      }
155
156      code.smartperf-yaml {
157        color: #153491;
158      }
159
160      /* Ruby */
161      .smartperf-ruby .tk.function {
162        color: #3f3e3e;
163      }
164
165      /* Markdown */
166      .smartperf-markdown .tk.url {
167        color: #6e5298;
168      }
169
170      /* Makefile */
171      .smartperf-makefile .tk.symbol {
172        color: #6c5393;
173      }
174
175      .smartperf-makefile .tk.variable {
176        color: #183488;
177      }
178
179      .smartperf-makefile .tk.builtin {
180        color: #027ba4;
181      }
182
183      /* Bash */
184      .smartperf-bash .tk.keyword {
185        color: #027fa9;
186      }
187
188      /* highlight */
189      pre[dl] {
190        position: relative;
191        padding: 1em 1px 1px 0.9em;
192      }
193
194      pre[dl] .line-highlight-wrapper {
195        position: absolute;
196        top: 1px;
197        left: 1px;
198        background-color: transparent;
199        display: block;
200        width: 99%;
201      }
202
203      pre[dl] .line-highlight {
204        position: absolute;
205        left: 1px;
206        right: 1px;
207        padding: inherit;
208        margin-top: 0.9em;
209        background: hsla(25, 21%, 50%, 0.08);
210        background: linear-gradient(to right, hsla(24, 20%, 50%, 0.1) 70%, hsla(24, 20%, 50%, 0));
211        pointer-events: none;
212        line-height: inherit;
213        white-space: pre;
214      }
215
216      pre[dl] .line-highlight:before,
217      pre[dl] .line-highlight[data-end]:after {
218        content: attr(data-start);
219        position: absolute;
220        text-shadow: none;
221        top: 0.3em;
222        left: 0.7em;
223        min-width: 0.9em;
224        padding: 1px 0.6em;
225        background-color: hsla(24, 20%, 47%, 0.4);
226        color: hsl(20, 11%, 95%);
227        text-align: center;
228        vertical-align: 0.2em;
229        border-radius: 10000px;
230        box-shadow: 1px 2px #fdf6f6;
231      }
232
233      pre[dl] .line-highlight[data-end]:after {
234        content: attr(data-end);
235        top: auto;
236        bottom: 0.5em;
237      }
238
239      html body {
240        line-height: 1.6;
241        font-size: 16px;
242        color: #333333;
243        overflow: initial;
244        word-wrap: break-word;
245        font-family: Helvetica;
246        box-sizing: border-box;
247      }
248
249      html body > :first-child {
250        margin-top: 0px;
251      }
252
253      html body h1,
254      html body h2,
255      html body h3,
256      html body h4,
257      html body h5,
258      html body h6 {
259        margin-top: 1em;
260        margin-bottom: 16px;
261        color: #000000;
262        line-height: 1.2;
263      }
264
265      html body h1 {
266        font-weight: 300;
267        font-size: 2.25em;
268        padding-bottom: 0.3em;
269      }
270
271      html body h2 {
272        font-weight: 410;
273        font-size: 1.74em;
274        padding-bottom: 0.2em;
275      }
276
277      html body h3 {
278        font-size: 1.6em;
279        font-weight: 501;
280      }
281
282      html body h4 {
283        font-size: 1.26em;
284        font-weight: 601;
285      }
286
287      html body h5 {
288        font-size: 1.2em;
289        font-weight: 601;
290      }
291
292      html body h6 {
293        font-size: 0.9em;
294        font-weight: 601;
295      }
296
297      html body h1,
298      html body h2,
299      html body h3,
300      html body h4,
301      html body h5 {
302        font-weight: 601;
303      }
304
305      html body h5 {
306        font-size: 0.9em;
307      }
308
309      html body h6 {
310        color: #5c5c5c;
311      }
312
313      html body strong {
314        color: #090909;
315      }
316
317      html body del {
318        color: #525252;
319      }
320
321      html body a:not([href]) {
322        color: inherit;
323        text-decoration: none;
324      }
325
326      html body a {
327        color: #0192da;
328        text-decoration: none;
329      }
330
331      html body a:hover {
332        color: #029dea;
333        text-decoration: none;
334      }
335
336      html body img {
337        max-width: 99%;
338      }
339
340      html body > p {
341        margin-top: 1px;
342        margin-bottom: 15px;
343        word-wrap: break-word;
344      }
345
346      html body > ul,
347      html body > ol {
348        margin-bottom: 15px;
349      }
350
351      html body ul,
352      html body ol {
353        padding-left: 1.9em;
354      }
355
356      html body ul.no-list,
357      html body ol.no-list {
358        padding: 0px;
359        list-style-type: none;
360      }
361
362      html body ul ul,
363      html body ul ol,
364      html body ol ol,
365      html body ol ul {
366        margin-top: 1px;
367        margin-bottom: 1px;
368      }
369
370      html body li {
371        margin-bottom: 1px;
372      }
373
374      html body li.task-list-item {
375        list-style: none;
376      }
377
378      html body li > p {
379        margin-top: 1px;
380        margin-bottom: 1px;
381      }
382
383      html body .task-list-item-checkbox {
384        margin: 0 0.3em 0.24em -1.7em;
385        vertical-align: middle;
386      }
387
388      html body .task-list-item-checkbox:hover {
389        cursor: pointer;
390      }
391
392      html body blockquote {
393        padding: 0.1px 15px 0 0.1px;
394        font-size: inherit;
395        color: #5c5c5c;
396        margin: 16px 0.1px 0 0.1px;
397        border-left: 3px solid #cbc9c9;
398        background-color: #e8e6e6;
399      }
400
401      html body blockquote > :first-child {
402        margin-top: 0.2px;
403      }
404
405      html body blockquote > :last-child {
406        margin-bottom: 0.1px;
407      }
408
409      html body hr {
410        height: 5px;
411        background-color: #cbcaca;
412        margin: 32px 0 0.1px 0;
413        border: 0 none;
414      }
415
416      html body table {
417        overflow: auto;
418        border-collapse: collapse;
419        margin: 15px 0.1px 20px 0.1px;
420        border-spacing: 0;
421      }
422
423      html body table th {
424        font-weight: bold;
425        color: #000000;
426      }
427
428      html body table td,
429      html body table th {
430        border: 1px solid #d6d6d6;
431        padding: 2px 14px;
432      }
433
434      html body dl {
435        padding: 0px;
436      }
437
438      html body dl dt {
439        padding: 0px;
440        margin-top: 15px;
441        font-size: 0.9em;
442        font-style: italic;
443        font-weight: bold;
444      }
445
446      html body dl dd {
447        padding: 0px 17px;
448        margin-bottom: 17px;
449      }
450
451      html body code {
452        font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
453        font-size: 0.86em !important;
454        color: #000000;
455        background-color: #f0f0f0;
456        border-radius: 4px;
457        padding: 0.3em 0px;
458      }
459
460      html body code::before,
461      html body code::after {
462        letter-spacing: -0.1em;
463        content: '\00a0';
464      }
465
466      html body pre > code {
467        padding: 1px;
468        margin: 0px;
469        font-size: 0.86em !important;
470        word-break: normal;
471        white-space: pre;
472        background: transparent;
473        border: 0px;
474      }
475
476      html body .highlight {
477        margin-bottom: 17px;
478      }
479
480      html body .highlight pre,
481      html body pre {
482        padding: 0.9em;
483        overflow: auto;
484        font-size: 0.86em !important;
485        line-height: 1.46;
486        border: #d6d6d6;
487        border-radius: 4px;
488      }
489
490      html body .highlight pre {
491        margin-bottom: 0px;
492        word-break: normal;
493      }
494
495      html body pre code,
496      html body pre tt {
497        display: inline;
498        max-width: initial;
499        padding: 1px;
500        margin: 1px;
501        overflow: initial;
502        line-height: inherit;
503        word-wrap: normal;
504        background-color: transparent;
505        border: 1px;
506      }
507
508      html body pre code:before,
509      html body pre tt:before,
510      html body pre code:after,
511      html body pre tt:after {
512        content: normal;
513      }
514
515      html body p,
516      html body blockquote,
517      html body ul,
518      html body ol,
519      html body dl,
520      html body pre {
521        margin-top: 1px;
522        margin-bottom: 17px;
523      }
524
525      html body kbd {
526        color: #000000;
527        border: 3px solid #d6d6d6;
528        border-bottom: 3px solid #c7c7c7;
529        padding: 3px 5px;
530        background-color: #f0f0f0;
531        border-radius: 2px;
532      }
533
534      @media print {
535        html body {
536          background-color: #ffffff;
537        }
538
539        html body h1,
540        html body h2,
541        html body h3,
542        html body h4,
543        html body h5,
544        html body h6 {
545          color: #000000;
546          page-break-after: avoid;
547        }
548
549        html body blockquote {
550          color: #5c5c53;
551        }
552
553        html body pre {
554          page-break-inside: avoid;
555        }
556
557        html body table {
558          display: table;
559        }
560
561        html body img {
562          display: block;
563          max-width: 99%;
564          max-height: 99%;
565        }
566
567        html body pre,
568        html body code {
569          word-wrap: break-word;
570          white-space: pre;
571        }
572      }
573
574      .smartperf-preview {
575        width: 68vw;
576        height: 99%;
577        box-sizing: border-box;
578        overflow: hidden;
579        background-color: #fff;
580      }
581
582      .smartperf-preview .pagebreak,
583      .smartperf-preview .newpage {
584        page-break-before: always;
585      }
586
587      .smartperf-preview pre.line-numbers {
588        position: relative;
589        padding-left: 3.7em;
590        counter-reset: linenumber;
591      }
592
593      .smartperf-preview pre.line-numbers > code {
594        position: relative;
595      }
596
597      .smartperf-preview pre.line-numbers .line-numbers-rows {
598        position: absolute;
599        pointer-events: none;
600        top: 0.9em;
601        font-size: 99%;
602        left: 1px;
603        width: 3em;
604        letter-spacing: -1px;
605        border-right: 1px solid #999;
606        -webkit-user-select: none;
607        -moz-user-select: none;
608        -ms-user-select: none;
609        user-select: none;
610      }
611
612      .smartperf-preview pre.line-numbers .line-numbers-rows > span {
613        pointer-events: none;
614        display: block;
615        counter-increment: linenumber;
616      }
617
618      .smartperf-preview pre.line-numbers .line-numbers-rows > span:before {
619        content: counter(linenumber);
620        color: #999;
621        display: block;
622        padding-right: 0.79em;
623        text-align: right;
624      }
625
626      .smartperf-preview .mathjax-exps .MathJax_Display {
627        text-align: center !important;
628      }
629
630      .smartperf-preview:not([for='preview']) .code-chunk .btn-group {
631        display: none;
632      }
633
634      .smartperf-preview:not([for='preview']) .code-chunk .status {
635        display: none;
636      }
637
638      .smartperf-preview:not([for='preview']) .code-chunk .output-div {
639        margin-bottom: 16px;
640      }
641
642      .scrollbar-style::-webkit-scrollbar {
643        width: 8px;
644      }
645
646      .scrollbar-style::-webkit-scrollbar-track {
647        border-radius: 9px;
648        background-color: transparent;
649      }
650
651      .scrollbar-style::-webkit-scrollbar-thumb {
652        border-radius: 6px;
653        background-color: rgba(150, 150, 150, 1);
654        border: 4px solid rgba(150, 150, 150, 1);
655        background-clip: content-box;
656      }
657
658      html body[for='html-export']:not([dpm]) {
659        position: relative;
660        width: 99%;
661        height: 99%;;
662        overflow: auto;
663      }
664
665      html body[for='html-export']:not([dpm]) .smartperf-preview {
666        position: relative;
667        top: 1px;
668      }
669
670      @media screen and (min-width: 914px) {
671        html body[for='html-export']:not([dpm]) .smartperf-preview {
672          padding: 2em;
673        }
674      }
675
676      @media screen and (max-width: 914px) {
677        html body[for='html-export']:not([dpm]) .smartperf-preview {
678          padding: 1.9em;
679        }
680      }
681
682      @media screen and (max-width: 450px) {
683        html body[for='html-export']:not([dpm]) .smartperf-preview {
684          font-size: 15px !important;
685          padding: 1.1em;
686        }
687      }
688
689      @media print {
690        html body[for='html-export']:not([dpm]) #sidebar-toc-btn {
691          display: none;
692        }
693      }
694
695      html body[for='html-export']:not([dpm]) #sidebar-toc-btn {
696        position: fixed;
697        bottom: 9px;
698        left: 9px;
699        font-size: 28px;
700        cursor: pointer;
701        color: inherit;
702        z-index: 99;
703        width: 31px;
704        text-align: center;
705        opacity: 0.5;
706      }
707
708      html body[for='html-export']:not([dpm])[hsst] #sidebar-toc-btn {
709        opacity: 1;
710      }
711
712      html body[for='html-export']:not([dpm])[hsst] .md-sidebar-toc {
713        position: fixed;
714        top: 1px;
715        left: 1px;
716        width: 300px;
717        height: 99%;
718        padding: 32px 0 48px 0;
719        font-size: 14px;
720        box-shadow: 1px 1px 4px rgba(150, 150, 150, 0.33);
721        box-sizing: border-box;
722        overflow: auto;
723        background-color: inherit;
724      }
725
726      html body[for='html-export']:not([dpm])[hsst] .md-sidebar-toc::-webkit-scrollbar {
727        width: 9px;
728      }
729
730      html body[for='html-export']:not([dpm])[hsst] .md-sidebar-toc::-webkit-scrollbar-track {
731        border-radius: 11px;
732        background-color: transparent;
733      }
734
735      html body[for='html-export']:not([dpm])[hsst] .md-sidebar-toc::-webkit-scrollbar-thumb {
736        border-radius: 6px;
737        background-color: rgba(150, 150, 150, 0.66);
738        border: 3px solid rgba(150, 150, 150, 0.66);
739        background-clip: content-box;
740      }
741
742      html body[for='html-export']:not([dpm])[hsst] .md-sidebar-toc a {
743        text-decoration: none;
744      }
745
746      html body[for='html-export']:not([dpm])[hsst] .md-sidebar-toc ul {
747        padding: 1px 1.7em;
748        margin-top: 0.9em;
749      }
750
751      html body[for='html-export']:not([dpm])[hsst] .md-sidebar-toc li {
752        margin-bottom: 0.8em;
753      }
754
755      html body[for='html-export']:not([dpm])[hsst] .md-sidebar-toc ul {
756        list-style-type: none;
757      }
758
759      html body[for='html-export']:not([dpm])[hsst] .smartperf-preview {
760        left: 301px;
761        width: calc(100% - 300px);
762        padding: 2em calc(50% - 457px - 150px);
763        margin: 1px;
764        box-sizing: border-box;
765      }
766
767      @media screen and (max-width: 1274px) {
768        html body[for='html-export']:not([dpm])[hsst] .smartperf-preview {
769          padding: 1.9em;
770        }
771      }
772
773      @media screen and (max-width: 450px) {
774        html body[for='html-export']:not([dpm])[hsst] .smartperf-preview {
775          width: 99%;
776        }
777      }
778
779      html body[for='html-export']:not([dpm]):not([hsst]) .md-sidebar-toc {
780        display: none;
781      }
782    </style>
783  </head>
784  <body for="html-export" id="body" style="margin:0">
785    <div class="smartperf smartperf-preview" style="min-height: 99vh;">
786      <h1 class="mume-header fontColor">Native Memory 抓取和展示说明</h1>
787
788      <p class="fontColor">Native Memory 是查看内存的分配和释放等情况。</p>
789      <h2 class="mume-header fontColor">Native Memory 的抓取</h2>
790
791      <h3 class="mume-header fontColor" id="header-index-1">Native Memory 抓取配置参数</h3>
792
793      <p class="fontColor"><img
794        src="../figures/NativeMemory/nativememorysetting.png"
795        alt="GitHub Logo"><br>
796        配置参数说明:
797      </p>
798      <ul class="fontColor">
799        <li>Process:设置抓取的进程 ID 或者进程名,此处以输入 com.ohos.mms 进程名为例。</li>
800        <li>Use Fp Unwind:是否Fp 回栈。</li>
801        <li>Use Record Statistics:统计数据上报时间间隔设置。</li>
802        <li>Use Record Js Stack:是否抓js栈。</li>
803      </ul>
804      <p class="fontColor">点击Advance Options进入高级配置界面<br>
805        <img
806          src="../figures/NativeMemory/nativememoryAdvoption.png"
807          alt="GitHub Logo">
808      </p>
809      <ul class="fontColor">
810        <li>Use Startup Mode: 抓取应用启动阶段的内存(默认是关闭,需要抓取应用启阶段内存可开启)。</li>
811        <li>Use Response Lib Mode:nativememory抓取支持So能力。</li>
812        <li>Use Record Accurately:不过滤数据,上报全量的。</li>
813        <li>Use Offline Symbolization:离线符号化。</li>
814        <li>Sample Interval:采样间隔。</li>
815        <li>Shared Memory Size:native_daemon 和 native_hook 进程之间存储数据的共享内存大小。</li>
816        <li>Max unwind level:抓取的栈的最大深度。</li>
817        <li>Max Js Stack Depth:抓取的Js栈的最大深度。</li>
818        <li>Filter Memory Size:只抓取大于该 size 的 malloc 数据(free 不受影响)。</li>
819        <li>Filter Napi Name:fp模式过滤某个napi调用。</li>
820      </ul>
821      <p class="fontColor">再点击 Record setting,在 output file path 输入文件名
822        hiprofiler_data_nativememory.htrace,拖动滚动条设置 buffer size 大小是 64MB,抓取时长是 50s。<br>
823        <img
824          src="../figures/NativeMemory/nativememoryset.png"
825          alt="GitHub Logo">
826      </p>
827      <p class="fontColor">点击 Trace command,就会根据上面的配置生成抓取命令,点击复制按钮,会将命令行复制。<br>
828        <img
829          src="../figures/NativeMemory/nativememorycommand.jpg"
830          alt="GitHub Logo"></p>
831      <p class="fontColor">命令行参数说明:
832      </p>
833      <ul class="fontColor">
834        <li>save_file:是否将 hook 数据保存成文件,不上报 protobuf 形式数据给 hiprofilerd。</li>
835        <li>filter_size:过滤 malloc 的大小,最小值是 0,默认值是 4096byte。</li>
836        <li>smb_pages:nativedeamon 与 libnativehook 间的共享内存大小。</li>
837        <li>max_stack_depth:最多回栈的层数,也就是抓取的栈的最大深度。</li>
838        <li>process_name:抓取的应用进程名。</li>
839        <li>string_compressed:是否进行字符串压缩。</li>
840        <li>fp_unwind:是否进行 fp 回栈。</li>
841        <li>callframe_compress: 是否进行栈帧压缩。</li>
842        <li>record_accurately: 是否不过滤数据,上报全量的。</li>
843        <li>offline_symbolization: 是否离线符号化。</li>
844        <li>statistics_interval: 统计模式下上报数据的时间间隔。</li>
845        <li>startup_mode: 是否需要抓取应用启动阶段内存。</li>
846      </ul>
847      <p class="fontColor">输入 hdc shell,进入设备,执行命令。<br>
848        <img
849          src="../figures/NativeMemory/nativeexcutecommand.jpg"
850          alt="GitHub Logo"><br>
851        执行完成后,进入指定目录查看,在/data/local/tmp 下就会生成 trace 文件。<br>
852        <img
853          src="../figures/NativeMemory/naitvememoryfile.jpg"
854          alt="GitHub Logo">
855      </p>
856      <h2 class="mume-header fontColor">Native Memory 展示说明</h2>
857
858      <p class="fontColor">将抓取的 Native Memory 文件导入到 smartperf
859        工具中查看,查看内存的分配和释放等情况。</p>
860      <h3 class="mume-header fontColor" id="header-index-2">Native Memory 泳道图展示类型</h3>
861
862      <p class="fontColor">点击齿轮状的图标可以设置内存的展示单位。<br>
863        <img
864          src="../figures/NativeMemory/NativeChart.png"
865          alt="GitHub Logo">
866      </p>
867      <ul class="fontColor">
868        <li>
869          <pre class="smartperf-text fontColor light">Current Bytes:以申请内存的size绘制泳道图。
870          </pre>
871        </li>
872        <li>
873          <pre class="smartperf-text fontColor light">Native Memory Density:以申请内存的数量绘制泳道图。
874          </pre>
875        </li>
876        <li>
877          <pre class="smartperf-text fontColor light">All Heap&amp;Anonymous VM:malloc分配和mmap分配的总量。
878          </pre>
879        </li>
880        <li>
881          <pre class="smartperf-text fontColor light">All Heap:malloc分配的内存。
882          </pre>
883        </li>
884        <li>
885          <pre class="smartperf-text fontColor light">All Anonymous VM:mmap分配的内存。
886          </pre>
887        </li>
888      </ul>
889      <h3 class="mume-header fontColor" id="header-index-3">Native Memory 泳道图的框选功能</h3>
890
891      <p class="fontColor">可以对内存的数据进行框选,框选后在最下方的弹出层中会展示框选数据的统计表格,总共有五个
892        tab 页。<br>
893        Statistics 的 Tab 页,主要显示了统计明细类型。<br>
894        <img
895          src="../figures/NativeMemory/Statistics.png"
896          alt="GitHub Logo">
897      </p>
898      <ul class="fontColor">
899        <li>
900          <pre class="smartperf-text fontColor light">Memory Type:内存的类型。
901          </pre>
902        </li>
903        <li>
904          <pre class="smartperf-text fontColor light">Existing:框选区间内申请没有释放的大小。
905          </pre>
906        </li>
907        <li>
908          <pre class="smartperf-text fontColor light">#Existing:框选区间内申请没有释放的次数。
909          </pre>
910        </li>
911        <li>
912          <pre class="smartperf-text fontColor light">Transient:框选区间内释放的大小。
913          </pre>
914        </li>
915        <li>
916          <pre class="smartperf-text fontColor light">#Transient:框选区间内释放的次数。
917          </pre>
918        </li>
919        <li>
920          <pre class="smartperf-text fontColor light">Total Bytes:框选区间内申请的大小。
921          </pre>
922        </li>
923        <li>
924          <pre class="smartperf-text fontColor light">#Total: 框选区间内申请的次数。
925          </pre>
926        </li>
927        <li>
928          <pre class="smartperf-text fontColor light">Peak Value: 框选区间内内存申请的峰值。
929          </pre>
930        </li>
931        <li>
932          <pre class="smartperf-text fontColor light">Existing/Total:框选区间内剩余的内存比上申请的内存,其中浅紫色是框选区间内申请的大小/整个时间轴(申请+释放的总大小),深紫色是框选区间内(申请+释放)的大小/整个时间轴(申请+释放的总大小)。
933          </pre>
934        </li>
935      </ul>
936      <p class="fontColor">Analysis 的 Tab 页,主要从Memory Type、Thread、Library、Function等维度展示内存统计信息。<br>
937        <img src="../figures/NativeMemory/Analysis.png" alt="GitHub Logo">
938      </p>
939      <p class="fontColor">Call Info 的 Tab 页,主要显示了调用树详细类型。<br>
940        <img
941          src="../figures/NativeMemory/CallInfo.png"
942          alt="GitHub Logo">
943      </p>
944      <ul class="fontColor">
945        <li>
946          <pre class="smartperf-text fontColor light">Symble Name:每个内存分配的调用栈。
947          </pre>
948        </li>
949        <li>
950          <pre class="smartperf-text fontColor light">Size:分配的总大小。
951          </pre>
952        </li>
953        <li>
954          <pre class="smartperf-text fontColor light">Count:相同调用栈出现的次数。
955          </pre>
956          Native Memory 的 Tab 页,主要显示了单次分配信息列表。<br>
957          <img
958            src="../figures/NativeMemory/NativeMemory.png"
959            alt="GitHub Logo"></li>
960        <li>
961          <pre class="smartperf-text fontColor light">Address:内存块的地址。
962          </pre>
963        </li>
964        <li>
965          <pre class="smartperf-text fontColor light">Memory Type:内存分配的类型。
966          </pre>
967        </li>
968        <li>
969          <pre class="smartperf-text fontColor light">Timestamp:时间戳信息。
970          </pre>
971        </li>
972        <li>
973          <pre class="smartperf-text fontColor light">State:内存地址当前状态Existed 表示框选区间内未释放,Freed表示已释放。
974          </pre>
975        </li>
976        <li>
977          <pre class="smartperf-text fontColor light">Size:该次申请分配内存的大小。
978          </pre>
979        </li>
980        <li>
981          <pre class="smartperf-text fontColor light">Responsible Library :调用该函数的库。
982          </pre>
983        </li>
984        <li>
985          <pre class="smartperf-text fontColor light">Responsible Caller  :调用该函数的方法。
986          </pre>
987          Snapshot List 的 Tab 页,主要显示了各时刻内存的增长的差值。<br>
988          <img
989            src="../figures/NativeMemory/Snapshotlist.png"
990            alt="GitHub Logo"></li>
991        <li>
992          <pre class="smartperf-text fontColor light">Snapshot:标记的打点说明。
993          </pre>
994        </li>
995        <li>
996          <pre class="smartperf-text fontColor light">Timestamp :时间戳信息。
997          </pre>
998        </li>
999        <li>
1000          <pre class="smartperf-text fontColor light">Net Growth :自从上次Snapshot的增长量,是计算分配和释放的。
1001          </pre>
1002        </li>
1003        <li>
1004          <pre class="smartperf-text fontColor light">Total Growth :自从上次Snapshot的增长量,是计算每一次分配的。
1005          </pre>
1006        </li>
1007        <li>
1008          <pre class="smartperf-text fontColor light">#Existing  :仍然存在的内存数。
1009          </pre>
1010        </li>
1011      </ul>
1012      <h3 class="mume-header fontColor" id="header-index-4">Native Memory 的辅助信息功能</h3>
1013
1014      <p class="fontColor">在 Call Info 和 Native Memory 的 Tab 页,点击选中某一行,右边画红线处会显示出该行调用栈的树结构信息。<br>
1015        <img
1016          src="../figures/NativeMemory/nativecallstack.png"
1017          alt="GitHub Logo">
1018      </p>
1019      <h3 class="mume-header fontColor" id="header-index-5">Native Memory 详细显示的过滤功能</h3>
1020
1021      <p class="fontColor">点击下方的 All Allocations 可以对 Allocation Lifespan 进行过滤,有三个选择:All
1022        Allocations,Created &amp; Existing,Created &amp; Destroyed。<br>
1023        <img
1024          src="../figures/NativeMemory/lifespan.jpg"
1025          alt="GitHub Logo">
1026      </p>
1027      <ul class="fontColor">
1028        <li>
1029          <pre class="smartperf-text fontColor light"> All Allocations:所有的内存。
1030          </pre>
1031        </li>
1032        <li>
1033          <pre class="smartperf-text fontColor light"> Created &amp; Existing:创建且被存活的内存。
1034          </pre>
1035        </li>
1036        <li>
1037          <pre class="smartperf-text fontColor light"> Created &amp; Destroyed: 创建且被销毁的内存。
1038          </pre>
1039          点击下方的 All Heap&amp;Anonymous 可以对内存类型进行过滤。<br>
1040          <img
1041            src="../figures/NativeMemory/AllocationType.jpg"
1042            alt="GitHub Logo"></li>
1043        <li>
1044          <pre class="smartperf-text fontColor light">All Heap&amp;Anonymous VM:Heap和Anonymous VM的总量。
1045          </pre>
1046        </li>
1047        <li>
1048          <pre class="smartperf-text fontColor light">All Heap:malloc分配的内存。
1049          </pre>
1050        </li>
1051        <li>
1052          <pre class="smartperf-text fontColor light">All Anonymous VM:mmap的匿名页。
1053          </pre>
1054          点击下方的 Mark Snapshot 可以在时间轴上打标签。出现小旗的标志,通过标注多个时间点。点击到
1055          Snapshot List 标签页可以看到各个时间点的内存的增长值。<br>
1056          <img
1057            src="../figures/NativeMemory/Generation.jpg"
1058            alt="GitHub Logo"></li>
1059      </ul>
1060      <h3 class="mume-header fontColor" id="header-index-6">Native Memory 的火焰图功能</h3>
1061
1062      <p class="fontColor">火焰图的展示跟 Call Info 的 tab 页的调用栈显示一致,鼠标放到色块上,悬浮框可以显示调用栈名称,栈的所在库名,地址,
1063        大小,采集次数。<br>
1064        <img
1065          src="../figures/NativeMemory/nativeflameshow.jpg"
1066          alt="GitHub Logo"></p>
1067      <h3 class="mume-header fontColor" id="header-index-7">
1068        基于函数进行调用栈(单个或多个)选择后可以在时间轴上显示内存操作点</h3>
1069
1070      <p class="fontColor">点击火焰图函数时,触发火焰图点击,显示调用栈中该函数出现在时间轴范围的分布情况。<br>
1071        <img
1072          src="../figures/NativeMemory/memoryframe.jpg"
1073          alt="GitHub Logo"></p>
1074      <h3 class="mume-header fontColor" id="header-index-8">
1075        内存搜索大小写不敏感,上层火焰图的大小和总内存需要根据搜索内容动态调整</h3>
1076
1077      <p class="fontColor">执行搜索的关键字大小写不区分,搜索的函数的 parent 只显示搜索的 children
1078        的大小之和,且可以与点选联动。</p>
1079      <h3 class="mume-header fontColor" id="header-index-9">焦点函数火焰图详细展开:选中函数的全部调用栈展示</h3>
1080
1081      <p class="fontColor">点击调用栈某个函数,点击函数调用的函数对应铺满画布,点击函数的
1082        parent,显示以及绘制的大小变化为点击函数的大小,如下图点击 OHOS::EglCoreInit()函数,会显示该函数的全部调用栈。<br>
1083        <img
1084          src="../figures/NativeMemory/eg_callstack.jpg"
1085          alt="GitHub Logo"></p>
1086      <h3 class="mume-header fontColor" id="header-index-10">搜索框支持表达式输入</h3>
1087
1088      <p class="fontColor">调用栈默认会显示火焰图,新增搜索框表达式输入。表达式作用范围为 nativehook
1089        的统计与非统计模式。其中处理的为 Responsible Library 与 Responsible Caller,其中 Responsible
1090        Library 和Responsible Caller 表示从下往上非 libc++ musl 的第一条调用栈的 lib 跟
1091        symbol,如下图所示,由于最后一条 [ operator new(unsigned long) ] <a href="http://libc++.so/">libc++.so</a>
1092        为 <a href="http://libc++.so/">libc++.so</a> 的函数,故跳过,所以该条调用栈的 Responsible Library
1093        为 <a href="http://libhilog.so/">libhilog.so</a>,Responsible Caller 为
1094        OHOS::HiviewDFX::GetDomainLevel(unsigned int) 。<br>
1095        <img
1096          src="../figures/NativeMemory/framecaller.jpg"
1097          alt="GitHub Logo"></p>
1098      <p class="fontColor">表达式说明: 在 InputFilter
1099        输入框可以进行搜索过滤和表达式过滤,其中表达式必须以@开头,英文括号包起所需要过滤的内容,每个括号必须包括
1100        (Responsible Library,Responsible Caller)匹配全量以*表示,否则认为该输入为搜索过滤。</p>
1101      <table class="fontColor">
1102        <thead>
1103        <tr>
1104          <th class="fontColor">表达式</th>
1105          <th class="fontColor">含义</th>
1106        </tr>
1107        </thead>
1108        <tbody>
1109        <tr>
1110          <td>@(libquickjs tryalloc)</td>
1111          <td>只显示 Responsible Library 为 libquickjs 且 Responsible Caller 包含 tryalloc 的数据</td>
1112        </tr>
1113        <tr>
1114          <td>@(libquickjs *)</td>
1115          <td>只显示 Responsible Library 包含 libquickjs 的数据</td>
1116        </tr>
1117        <tr>
1118          <td>@(* tryalloc codec bitmapcache skYUV)</td>
1119          <td>只显示 Responsible Library 为任意值 且 Responsible Caller 包含 tryalloc 或 codec 或
1120            bitmapcache 或 skYUV 的数据
1121          </td>
1122        </tr>
1123        <tr>
1124          <td>@(libglobal *,*resourceManager)</td>
1125          <td>只显示 Responsible Library 包含 libglobal 且 Responsible Caller 为任意值的数据 或
1126            Responsible Library 为任意值,Responsible Caller 包含 resourceManager 的数据
1127          </td>
1128        </tr>
1129        <tr>
1130          <td>@(/data/user *)</td>
1131          <td>只显示 Responsible Library 路径/data/user 且 symbol 为任意值的数据</td>
1132        </tr>
1133        <tr>
1134          <td>@(<a href="http://mali.so/">mali.so</a> *,libGLES_mali.so *)</td>
1135          <td>只显示 Responsible Library 包含 <a href="http://mali.so/">mali.so</a> 或者 libGLES_mali.so
1136            的数据
1137          </td>
1138        </tr>
1139        <tr>
1140          <td>@(* PixelMap:ReadImageData)</td>
1141          <td>只显示 Responsible Caller 包含 PixelMap:ReadImageData 的数据</td>
1142        </tr>
1143        <tr>
1144          <td></td>
1145          <td></td>
1146        </tr>
1147        <tr>
1148          <td>@-(libark jsvm table)</td>
1149          <td>不显示 Responsible Library 包含 libark 且 Responsible Caller 包含 jsvm 或者 table 的数据
1150          </td>
1151        </tr>
1152        <tr>
1153          <td>@-(librender picture, libskia picture) <br></td>
1154          <td>不显示 Responsible Library 包含 librender 或者 libskia 且 Responsible Caller 中包含
1155            picture 的数据
1156          </td>
1157        </tr>
1158        <tr>
1159          <td>@-(libark *)</td>
1160          <td>不显示 Responsible Library 包含 libark 的数据</td>
1161        </tr>
1162        <tr>
1163          <td>@-(* table)</td>
1164          <td>不显示 Responsible Caller 中 table 的数据</td>
1165        </tr>
1166        <tr>
1167          <td></td>
1168          <td></td>
1169        </tr>
1170        <tr>
1171          <td>@(_ table) - (libark _)</td>
1172          <td>只显示 Responsible Caller 包含 table 且 Responsible Library 不为 libark 的数据</td>
1173        </tr>
1174        </tbody>
1175      </table>
1176      <h3 class="mume-header fontColor" id="header-index-11">Native Memory 数据统计功能</h3>
1177
1178      <p class="fontColor">选择 Use Record Statistics 和 statistics interval 配置项抓取的数据,只会显示
1179        Call Info 的 Tab 页,Call Info 相关功能同上。<br>
1180        <img
1181          src="../figures/NativeMemory/statiscsCallInfo.jpg"
1182          alt="GitHub Logo">
1183      </p>
1184      <h3 class="mume-header fontColor" id="header-index-12">Native Memory 多进程数据显示</h3>
1185
1186      <p class="fontColor">前端可以支持多进程数据的展示,通过在 tab 页切换不同进程,可以显示不同进程的
1187        hook 数据。<br>
1188        <img
1189          src="../figures/NativeMemory/hook_moreprocess.jpg"
1190          alt="GitHub Logo">
1191      </p>
1192    </div>
1193
1194    <script>
1195      window.onload = () => {
1196        let isDark = getURLParameter('dark'); 
1197        let targetId = getURLParameter('targetId'); 
1198        let isBack = getURLParameter('isBack'); 
1199        if (isDark === 'true') {
1200          document.getElementById('body').setAttribute('style', 'background-color:#272C34;');
1201          let header = document.getElementsByClassName('fontColor');
1202          for (let i = 0; i < header.length; i++) {
1203            header[i].style.color = '#fff';
1204          }
1205          let lightBackGround = document.getElementsByClassName('light');
1206          for (let i = 0; i < lightBackGround.length; i++) {
1207            lightBackGround[i].style.backgroundColor = '#32373F';
1208          }
1209        }
1210        function getURLParameter(name) {  
1211          return (new URL(document.location)).searchParams.get(name);  
1212        }  
1213  
1214        if ( targetId !== null ) {
1215          let targetElement = document.getElementById(targetId);
1216          targetElement.scrollIntoView({ behavior: 'smooth' });
1217        }
1218      };
1219    </script>
1220  </body>
1221</html>
1222