提交 f73203ff 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 58420267
# HiDebug # HiDebug
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
You can run the hidebug command 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. You can also export VM memory slices and collect VM CPU profiling data. You can run the hidebug command 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. You can also export VM memory slices and collect VM CPU profiling data.
## Modules to Import ## Modules to Import
``` ```js
import hidebug from '@ohos.hidebug'; import hidebug from '@ohos.hidebug';
``` ```
...@@ -18,9 +18,11 @@ getNativeHeapSize(): bigint ...@@ -18,9 +18,11 @@ getNativeHeapSize(): bigint
Obtains the total size of the native heap memory. Obtains the total size of the native heap memory.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------------------- | | ------ | --------------------------- |
...@@ -28,7 +30,7 @@ Obtains the total size of the native heap memory. ...@@ -28,7 +30,7 @@ Obtains the total size of the native heap memory.
**Example** **Example**
``` ```js
let nativeHeapSize = hidebug.getNativeHeapSize(); let nativeHeapSize = hidebug.getNativeHeapSize();
``` ```
...@@ -39,17 +41,19 @@ getNativeHeapAllocatedSize(): bigint ...@@ -39,17 +41,19 @@ getNativeHeapAllocatedSize(): bigint
Obtains the size of the allocated native heap memory. Obtains the size of the allocated native heap memory.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------------------------- | | ------ | --------------------------------- |
| bigint | Size of the allocated native heap memory.| | bigint | Size of the allocated native heap memory.|
**Example** **Example**
``` ```js
let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize();
``` ```
...@@ -60,17 +64,19 @@ getNativeHeapFreeSize(): bigint ...@@ -60,17 +64,19 @@ getNativeHeapFreeSize(): bigint
Obtains the size of the free native heap memory. Obtains the size of the free native heap memory.
This API is defined but not implemented in OpenHarmony 3.1 Release.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------------- | | ------ | ------------------------------- |
| bigint | Size of the free native heap memory.| | bigint | Size of the free native heap memory.|
**Example** **Example**
``` ```js
let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize();
``` ```
...@@ -84,14 +90,14 @@ Obtains the PSS of this process. ...@@ -84,14 +90,14 @@ Obtains the PSS of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------- | | ------ | ------------------------- |
| bigint | PSS of the process.| | bigint | PSS of the process.|
**Example** **Example**
``` ```js
let pss = hidebug.getPss(); let pss = hidebug.getPss();
``` ```
...@@ -105,17 +111,58 @@ Obtains the size of the shared dirty memory of this process. ...@@ -105,17 +111,58 @@ Obtains the size of the shared dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return Value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------------------- | | ------ | -------------------------- |
| bigint | Size of the shared dirty memory of the process.| | bigint | Size of the shared dirty memory of the process.|
**Example** **Example**
``` ```js
let sharedDirty = hidebug.getSharedDirty(); let sharedDirty = hidebug.getSharedDirty();
``` ```
## hidebug.getPrivateDirty<sup>9+<sup>
getPrivateDirty(): bigint
Obtains the size of the private dirty memory of this process.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
| Type | Description |
| ------ | -------------------------- |
| bigint | Size of the private dirty memory of the process.|
**Example**
```js
let privateDirty = hidebug.getPrivateDirty();
```
## hidebug.getCpuUsage<sup>9+<sup>
getCpuUsage(): number
Obtains the CPU usage of this process.
For example, if the CPU usage is **50%**, **0.5** is returned.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Return value**
| Type | Description |
| ------ | -------------------------- |
| number | CPU usage of the process.|
**Example**
```js
let cpuUsage = hidebug.getCpuUsage();
```
## hidebug.startProfiling ## hidebug.startProfiling
...@@ -135,9 +182,9 @@ Starts the profiling method. `startProfiling()` and `stopProfiling()` are called ...@@ -135,9 +182,9 @@ Starts the profiling method. `startProfiling()` and `stopProfiling()` are called
```js ```js
hidebug.startProfiling("cpuprofiler-20220216"); hidebug.startProfiling("cpuprofiler-20220216");
// Code block // code block
// ... // ...
// Code block // code block
hidebug.stopProfiling(); hidebug.stopProfiling();
``` ```
...@@ -147,7 +194,7 @@ hidebug.stopProfiling(); ...@@ -147,7 +194,7 @@ hidebug.stopProfiling();
stopProfiling() : void stopProfiling() : void
Stops the profiling method. `stopProfiling()` and `startProfiling()` are called in pairs. `stopProfiling()` always occurs after `startProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. Stops the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
...@@ -155,9 +202,9 @@ Stops the profiling method. `stopProfiling()` and `startProfiling()` are called ...@@ -155,9 +202,9 @@ Stops the profiling method. `stopProfiling()` and `startProfiling()` are called
```js ```js
hidebug.startProfiling("cpuprofiler-20220216"); hidebug.startProfiling("cpuprofiler-20220216");
// Code block // code block
// ... // ...
// Code block // code block
hidebug.stopProfiling(); hidebug.stopProfiling();
``` ```
...@@ -165,13 +212,13 @@ hidebug.stopProfiling(); ...@@ -165,13 +212,13 @@ hidebug.stopProfiling();
dumpHeapData(filename : string) : void dumpHeapData(filename : string) : void
Exports the heap data. Exports data from the specified heap file.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.| | filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.|
...@@ -180,3 +227,31 @@ Exports the heap data. ...@@ -180,3 +227,31 @@ Exports the heap data.
```js ```js
hidebug.dumpHeapData("heap-20220216"); hidebug.dumpHeapData("heap-20220216");
``` ```
## hidebug.getServiceDump<sup>9+<sup>
getServiceDump(serviceid : number) : string
Obtains information on the specified system service.
This is a system API and cannot be called by third-party applications.
**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| serviceid | number | Yes | ID of the system service. |
**Return value**
| Type | Description |
| ------ | -------------------------- |
| string | Absolute path of the file that contains the service information to dump. |
**Example**
```js
let serviceId = 10;
let pathName = hidebug.getServiceDump(serviceId);
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册