Name Date Size

..25-Oct-20244 KiB

.gitignoreH A D25-Oct-2024119

AppScope/H25-Oct-20244 KiB

build-profile.json5H A D25-Oct-20241.1 KiB

entry/H25-Oct-20244 KiB

hvigor/H25-Oct-20244 KiB

hvigorfile.tsH A D25-Oct-2024768

hvigorwH A D25-Oct-20242.1 KiB

hvigorw.batH A D25-Oct-20242 KiB

oh-package.json5H A D25-Oct-2024842

ohosTest.mdH A D25-Oct-2024551

README.mdH A D25-Oct-20241.3 KiB

README_zh.mdH A D25-Oct-20241.9 KiB

screenshots/device/H25-Oct-20244 KiB

README.md

1# HiDebug
2
3### Introduction
4
5This sample shows how to use HiDebug APIs to obtain the memory usage of an application. The display effect is as follows:
6
7![](screenshots/device/index.jpeg) ![](screenshots/device/data.jpeg)
8
9### Concepts
10
11**HiDebug**: a module that allows you to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. It also allows you to export VM memory slices and collect VM CPU profiling data.
12
13**Stack**: a component that provides a stack container where child components are successively stacked and the latter one overwrites the previous one.
14
15**@Builder**: a decorator used for a method to define the declarative UI description of a component and quickly generate multiple layouts in a custom component.
16
17### Required Permissions
18
19N/A
20
21### Usage
22
231. Touch the **Debug** icon in the upper right corner of the page. The debugging information page is displayed, showing the memory usage of the application.
24
252. Touch the **Debug** icon again. The debugging information page disappears.
26
27### Constraints
28
291. This sample can only be run on standard-system devices.
30
312. This sample is based on the stage model, which is supported from API version 9.
32
333. DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) must be used.
34

README_zh.md

1# Debug
2
3### 介绍
4
5本示例通过使用[@ohos.hidebug](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-performance-analysis-kit/js-apis-hidebug.md) 接口来获取当前应用内存使用情况。
6
7### 效果预览
8
9|主页|Debug数据|
10|--------------------------------|--------------------------------|
11|![](screenshots/device/index.jpeg)|![](screenshots/device/data.jpeg)|
12
13使用说明
14
151.点击界面右上方Debug图标,弹出Debug信息界面,显示当前应用内存使用情况;
16
172.再次点击右上方Debug图标,Debug信息界面消失。
18
19### 工程目录
20
21```
22entry/src/main/ets/
23|---Application
24|---component
25|   |---DebugInfo.ets                  // Debug信息页面
26|---data
27|   |---Logger.ts                      // 日志工具
28|---MainAbility
29|---pages
30|   |---Index.ets                      // 首页
31```
32### 具体实现
33
34* 本实例获取Debug信息的功能结主要封装在Index,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets) 。
35    * 获取Debug信息:在Index页面中通过点击事件调用hidebug.getPss()、hidebug.getSharedDirty()、hidebug.getPrivateDirty()等方法能够获取应用进程实际使用的物理内存大小、进程的共享脏内存大小、进程的私有脏内存大小。
36
37### 相关权限
38
39不涉及。
40
41### 依赖
42
43不涉及。
44
45### 约束与限制
46
471.本示例仅支持标准系统上运行。
48
492.本示例已适配API version 11版本SDK,版本号:4.1.3.3。
50
513.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400 构建 2023年4月7日)及以上版本才可编译运行。
52
53### 下载
54
55如需单独下载本工程,执行如下命令:
56```
57git init
58git config core.sparsecheckout true
59echo code/BasicFeature/DFX/Debug/ > .git/info/sparse-checkout
60git remote add origin https://gitee.com/openharmony/applications_app_samples.git
61git pull origin master
62
63```
64