1/* 2* Copyright (C) 2022 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15 16/** 17 * @file 18 * @kit PerformanceAnalysisKit 19 */ 20 21/** 22 * Provide interfaces related to debugger access and obtaining CPU, 23 * memory and other virtual machine information during runtime for JS programs 24 * 25 * @namespace hidebug 26 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 27 * @since 8 28 */ 29 30/** 31 * Provide interfaces related to debugger access and obtaining CPU, 32 * memory and other virtual machine information during runtime for JS programs 33 * 34 * @namespace hidebug 35 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 36 * @atomicservice 37 * @since 12 38 */ 39 40declare namespace hidebug { 41 /** 42 * Get total native heap memory size 43 * 44 * @returns { bigint } Returns total native heap memory size. 45 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 46 * @since 8 47 */ 48 function getNativeHeapSize(): bigint; 49 50 /** 51 * Get Native heap memory allocation size. 52 * @returns { bigint } Returns native heap memory allocation size. 53 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 54 * @since 8 55 */ 56 function getNativeHeapAllocatedSize(): bigint; 57 58 /** 59 * Get Native heap memory free size 60 * 61 * @returns { bigint } Returns native heap memory free size. 62 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 63 * @since 8 64 */ 65 function getNativeHeapFreeSize(): bigint; 66 67 /** 68 * Get the virtual set size memory of the application process 69 * 70 * @returns { bigint } Returns application process virtual set size memory information. 71 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 72 * @since 11 73 */ 74 function getVss(): bigint; 75 76 /** 77 * Get application process proportional set size memory information 78 * 79 * @returns { bigint } Returns application process proportional set size memory information. 80 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 81 * @since 8 82 */ 83 function getPss(): bigint; 84 85 /** 86 * Obtains the size of the shared dirty memory of a process. 87 * 88 * @returns { bigint } Returns the size of the shared dirty memory. 89 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 90 * @since 8 91 */ 92 function getSharedDirty(): bigint; 93 94 /** 95 * Obtains the size of the private dirty memory of a process. 96 * @returns { bigint } Returns the size of the private dirty memory. 97 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 98 * @since 9 99 */ 100 function getPrivateDirty(): bigint; 101 102 /** 103 * Obtains the cpu usage percent of a process. 104 * 105 * @returns { number } Returns the cpu usage of a process. 106 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 107 * @since 9 108 */ 109 function getCpuUsage(): number; 110 111 /** 112 * Start CPU Profiling. 113 * The input parameter is a user-defined file name, excluding the file suffix. 114 * The generated file is in the files folder under the application directory. 115 * Such as "/data/accounts/account_0/appdata/[package name]/files/cpuprofiler-xxx.json" 116 * 117 * @param { string } filename - Indicates the user-defined file name, excluding the file suffix. 118 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 119 * @since 8 120 * @deprecated since 9 121 * @useinstead ohos.hidebug/hidebug.startJsCpuProfiling 122 */ 123 function startProfiling(filename: string): void; 124 125 /** 126 * Stop CPU Profiling. 127 * It takes effect only when the CPU profiler is turned on 128 * 129 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 130 * @since 8 131 * @deprecated since 9 132 * @useinstead ohos.hidebug/hidebug.stopJsCpuProfiling 133 */ 134 function stopProfiling(): void; 135 136 /** 137 * Dump JS Virtual Machine Heap Snapshot. 138 * The input parameter is a user-defined file name, excluding the file suffix. 139 * The generated file is in the files folder under the application directory. 140 * Such as "/data/accounts/account_0/appdata/[package name]/files/xxx.heapsnapshot" 141 * 142 * @param { string } filename - Indicates the user-defined file name, excluding the file suffix. 143 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 144 * @since 8 145 * @deprecated since 9 146 * @useinstead ohos.hidebug/hidebug.dumpJsHeapData 147 */ 148 function dumpHeapData(filename: string): void; 149 150 /** 151 * Start CPU Profiling. 152 * The input parameter is a user-defined file name, excluding the file suffix. 153 * The generated file is in the files folder under the application directory. 154 * 155 * @param { string } filename - Indicates the user-defined file name, excluding the file suffix. 156 * @throws {BusinessError} 401 - the parameter check failed, Parameter type error 157 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 158 * @since 9 159 */ 160 function startJsCpuProfiling(filename: string): void; 161 162 /** 163 * Stop CPU Profiling. 164 * It takes effect only when the CPU profiler is turned on 165 * 166 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 167 * @since 9 168 */ 169 function stopJsCpuProfiling(): void; 170 171 /** 172 * Dump JS Virtual Machine Heap Snapshot. 173 * The input parameter is a user-defined file name, excluding the file suffix. 174 * The generated file is in the files folder under the application directory. 175 * 176 * @param { string } filename - Indicates the user-defined file name, excluding the file suffix. 177 * @throws {BusinessError} 401 - the parameter check failed, Parameter type error 178 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 179 * @since 9 180 */ 181 function dumpJsHeapData(filename: string): void; 182 183 /** 184 * Get a debugging dump of a system service by service id. 185 * It need dump permission. 186 * This API can be called only by system application. 187 * 188 * @permission ohos.permission.DUMP 189 * @param { number } serviceid - Indicates the id of the service ability. 190 * @param { number } fd - The file descriptor. 191 * @param { Array<string> } args - The args list of the system ability dump interface. 192 * @throws {BusinessError} 401 - the parameter check failed, Possible causes: 193 * 1.the parameter type error 194 * 2.the args parameter is not string array 195 * @throws {BusinessError} 11400101 - ServiceId invalid. The system ability does not exist. 196 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 197 * @since 9 198 */ 199 function getServiceDump(serviceid: number, fd: number, args: Array<string>): void; 200 201 /** 202 * Obtains the cpu usage of system. 203 * 204 * @returns { number } Returns the cpu usage of system. 205 * @throws { BusinessError } 11400104 - The status of the system CPU usage is abnormal. 206 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 207 * @since 12 208 */ 209 function getSystemCpuUsage(): number; 210 211 /** 212 * Application CPU usage of thread. 213 * 214 * @interface ThreadCpuUsage 215 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 216 * @since 12 217 */ 218 interface ThreadCpuUsage { 219 /** 220 * Thread id 221 * 222 * @type { number } 223 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 224 * @since 12 225 */ 226 threadId: number; 227 /** 228 * Cpu usage of thread 229 * 230 * @type { number } 231 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 232 * @since 12 233 */ 234 cpuUsage: number; 235 } 236 237 /** 238 * Get the CPU usage of all threads in the application. 239 * 240 * @returns { ThreadCpuUsage[] } Returns the CPU usage of all threads in the application. 241 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 242 * @since 12 243 */ 244 function getAppThreadCpuUsage(): ThreadCpuUsage[]; 245 246 /** 247 * System memory information 248 * 249 * @interface SystemMemInfo 250 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 251 * @since 12 252 */ 253 interface SystemMemInfo { 254 /** 255 * Total system memory size, in kilobyte 256 * 257 * @type { bigint } 258 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 259 * @since 12 260 */ 261 totalMem: bigint; 262 /** 263 * System free memory size, in kilobyte 264 * 265 * @type { bigint } 266 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 267 * @since 12 268 */ 269 freeMem: bigint; 270 /** 271 * System available memory size, in kilobyte 272 * 273 * @type { bigint } 274 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 275 * @since 12 276 */ 277 availableMem: bigint; 278 } 279 280 /** 281 * Obtains the system memory size. 282 * 283 * @returns { SystemMemInfo } Returns system memory size. 284 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 285 * @since 12 286 */ 287 function getSystemMemInfo(): SystemMemInfo; 288 289 /** 290 * Application process native memory information. 291 * 292 * @interface NativeMemInfo 293 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 294 * @since 12 295 */ 296 interface NativeMemInfo { 297 /** 298 * Process proportional set size memory, in kilobyte 299 * 300 * @type { bigint } 301 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 302 * @since 12 303 */ 304 pss: bigint; 305 /** 306 * Virtual set size memory, in kilobyte 307 * 308 * @type { bigint } 309 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 310 * @since 12 311 */ 312 vss: bigint; 313 /** 314 * Resident set size, in kilobyte 315 * 316 * @type { bigint } 317 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 318 * @since 12 319 */ 320 rss: bigint; 321 /** 322 * The size of the shared dirty memory, in kilobyte 323 * 324 * @type { bigint } 325 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 326 * @since 12 327 */ 328 sharedDirty: bigint; 329 /** 330 * The size of the private dirty memory, in kilobyte 331 * 332 * @type { bigint } 333 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 334 * @since 12 335 */ 336 privateDirty: bigint; 337 /** 338 * The size of the shared clean memory, in kilobyte 339 * 340 * @type { bigint } 341 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 342 * @since 12 343 */ 344 sharedClean: bigint; 345 /** 346 * The size of the private clean memory, in kilobyte 347 * 348 * @type { bigint } 349 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 350 * @since 12 351 */ 352 privateClean: bigint; 353 } 354 355 /** 356 * Obtains the memory information of application process. 357 * 358 * @returns { NativeMemInfo } Returns the native memory of a process. 359 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 360 * @since 12 361 */ 362 function getAppNativeMemInfo(): NativeMemInfo; 363 364 /** 365 * Application process memory limit 366 * 367 * @interface MemoryLimit 368 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 369 * @since 12 370 */ 371 interface MemoryLimit { 372 /** 373 * The limit of the application process's resident set, in kilobyte 374 * 375 * @type { bigint } 376 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 377 * @since 12 378 */ 379 rssLimit: bigint; 380 /** 381 * The limit of the application process's virtual memory, in kilobyte 382 * 383 * @type { bigint } 384 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 385 * @since 12 386 */ 387 vssLimit: bigint; 388 /** 389 * The limit of the js vm heap size of current virtual machine, in kilobyte 390 * 391 * @type { bigint } 392 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 393 * @since 12 394 */ 395 vmHeapLimit: bigint; 396 /** 397 * The limit of the total js vm heap size of process, in kilobyte 398 * 399 * @type { bigint } 400 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 401 * @since 12 402 */ 403 vmTotalHeapSize: bigint; 404 } 405 406 /** 407 * Obtains the memory limit of application process. 408 * 409 * @returns { MemoryLimit } Returns memory limit of application. 410 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 411 * @since 12 412 */ 413 function getAppMemoryLimit(): MemoryLimit; 414 415 /** 416 * The memory information of application virtual machine. 417 * 418 * @interface VMMemoryInfo 419 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 420 * @since 12 421 */ 422 interface VMMemoryInfo { 423 /** 424 * Total size of current virtual machine Heap, in kilobyte 425 * 426 * @type { bigint } 427 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 428 * @since 12 429 */ 430 totalHeap: bigint; 431 /** 432 * Used size of current virtual machine Heap, in kilobyte 433 * 434 * @type { bigint } 435 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 436 * @since 12 437 */ 438 heapUsed: bigint; 439 /** 440 * All array object size of current virtual machine, in kilobyte 441 * 442 * @type { bigint } 443 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 444 * @since 12 445 */ 446 allArraySize: bigint; 447 } 448 449 /** 450 * Obtains the memory information of application virtual machine. 451 * 452 * @returns { VMMemoryInfo } Returns memory information of application virtual machine. 453 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 454 * @since 12 455 */ 456 function getAppVMMemoryInfo(): VMMemoryInfo; 457 458 /** 459 * Enum for trace flag 460 * 461 * @enum { number } 462 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 463 * @since 12 464 */ 465 enum TraceFlag { 466 /** 467 * Only capture main thread trace 468 * 469 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 470 * @since 12 471 */ 472 MAIN_THREAD = 1, 473 /** 474 * Capture all thread trace 475 * 476 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 477 * @since 12 478 */ 479 ALL_THREADS = 2 480 } 481 482 /** 483 * Provide trace tags 484 * 485 * @namespace tags 486 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 487 * @since 12 488 */ 489 namespace tags { 490 /** 491 * Ability Manager tag. 492 * 493 * @constant 494 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 495 * @since 12 496 */ 497 const ABILITY_MANAGER: number; 498 /** 499 * ARKUI development framework tag. 500 * 501 * @constant 502 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 503 * @since 12 504 */ 505 const ARKUI: number; 506 /** 507 * ARK tag. 508 * 509 * @constant 510 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 511 * @since 12 512 */ 513 const ARK: number; 514 /** 515 * Bluetooth tag. 516 * 517 * @constant 518 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 519 * @since 12 520 */ 521 const BLUETOOTH: number; 522 /** 523 * Common library subsystem tag. 524 * 525 * @constant 526 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 527 * @since 12 528 */ 529 const COMMON_LIBRARY: number; 530 /** 531 * Distributed hardware device manager tag. 532 * 533 * @constant 534 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 535 * @since 12 536 */ 537 const DISTRIBUTED_HARDWARE_DEVICE_MANAGER: number; 538 /** 539 * Distributed audio tag. 540 * 541 * @constant 542 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 543 * @since 12 544 */ 545 const DISTRIBUTED_AUDIO: number; 546 /** 547 * Distributed camera tag. 548 * 549 * @constant 550 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 551 * @since 12 552 */ 553 const DISTRIBUTED_CAMERA: number; 554 /** 555 * Distributed data manager module tag. 556 * 557 * @constant 558 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 559 * @since 12 560 */ 561 const DISTRIBUTED_DATA: number; 562 /** 563 * Distributed hardware framework tag. 564 * 565 * @constant 566 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 567 * @since 12 568 */ 569 const DISTRIBUTED_HARDWARE_FRAMEWORK: number; 570 /** 571 * Distributed input tag. 572 * 573 * @constant 574 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 575 * @since 12 576 */ 577 const DISTRIBUTED_INPUT: number; 578 /** 579 * Distributed screen tag. 580 * 581 * @constant 582 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 583 * @since 12 584 */ 585 const DISTRIBUTED_SCREEN: number; 586 /** 587 * Distributed scheduler tag. 588 * 589 * @constant 590 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 591 * @since 12 592 */ 593 const DISTRIBUTED_SCHEDULER: number; 594 /** 595 * FFRT tasks. 596 * 597 * @constant 598 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 599 * @since 12 600 */ 601 const FFRT: number; 602 /** 603 * File management tag. 604 * 605 * @constant 606 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 607 * @since 12 608 */ 609 const FILE_MANAGEMENT: number; 610 /** 611 * Global resource manager tag. 612 * 613 * @constant 614 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 615 * @since 12 616 */ 617 const GLOBAL_RESOURCE_MANAGER: number; 618 /** 619 * Graphics module tag. 620 * 621 * @constant 622 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 623 * @since 12 624 */ 625 const GRAPHICS: number; 626 /** 627 * HDF subsystem tag. 628 * 629 * @constant 630 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 631 * @since 12 632 */ 633 const HDF: number; 634 /** 635 * MISC module tag. 636 * 637 * @constant 638 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 639 * @since 12 640 */ 641 const MISC: number; 642 /** 643 * Multimodal input module tag. 644 * 645 * @constant 646 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 647 * @since 12 648 */ 649 const MULTIMODAL_INPUT: number; 650 /** 651 * Net tag. 652 * 653 * @constant 654 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 655 * @since 12 656 */ 657 const NET: number; 658 /** 659 * Notification module tag. 660 * 661 * @constant 662 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 663 * @since 12 664 */ 665 const NOTIFICATION: number; 666 /** 667 * NWeb tag. 668 * 669 * @constant 670 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 671 * @since 12 672 */ 673 const NWEB: number; 674 /** 675 * OHOS generic tag. 676 * 677 * @constant 678 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 679 * @since 12 680 */ 681 const OHOS: number; 682 /** 683 * Power manager tag. 684 * 685 * @constant 686 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 687 * @since 12 688 */ 689 const POWER_MANAGER: number; 690 /** 691 * RPC tag. 692 * 693 * @constant 694 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 695 * @since 12 696 */ 697 const RPC: number; 698 /** 699 * SA tag. 700 * 701 * @constant 702 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 703 * @since 12 704 */ 705 const SAMGR: number; 706 /** 707 * Window manager tag. 708 * 709 * @constant 710 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 711 * @since 12 712 */ 713 const WINDOW_MANAGER: number; 714 /** 715 * Audio module tag. 716 * 717 * @constant 718 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 719 * @since 12 720 */ 721 const AUDIO: number; 722 /** 723 * Camera module tag. 724 * 725 * @constant 726 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 727 * @since 12 728 */ 729 const CAMERA: number; 730 /** 731 * Image module tag. 732 * 733 * @constant 734 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 735 * @since 12 736 */ 737 const IMAGE: number; 738 /** 739 * Media module tag. 740 * 741 * @constant 742 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 743 * @since 12 744 */ 745 const MEDIA: number; 746 } 747 748 /** 749 * Start capture application trace. 750 * 751 * @param { number[] } tags - Tag of trace. 752 * @param { TraceFlag } flag - Trace flag. 753 * @param { number } limitSize - Max size of trace file, in bytes, the max is 500MB. 754 * @returns { string } Returns absolute path of the trace file. 755 * @throws { BusinessError } 401 - Invalid argument, Possible causes: 756 * 1.The limit parameter is too small 757 * 2.The parameter is not within the enumeration type 758 * 3.The parameter type error or parameter order error 759 * @throws { BusinessError } 11400102 - Capture trace already enabled. 760 * @throws { BusinessError } 11400103 - No write permission on the file. 761 * @throws { BusinessError } 11400104 - Abnormal trace status. 762 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 763 * @since 12 764 */ 765 function startAppTraceCapture(tags: number[], flag: TraceFlag, limitSize: number): string; 766 767 /** 768 * Stop capture application trace. 769 * 770 * @throws { BusinessError } 11400104 - The status of the trace is abnormal 771 * @throws { BusinessError } 11400105 - No capture trace running 772 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 773 * @since 12 774 */ 775 function stopAppTraceCapture(): void; 776 777 /** 778 * Collection statistics. 779 * 780 * @typedef { Record<string, number> } GcStats 781 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 782 * @since 12 783 */ 784 type GcStats = Record<string, number>; 785 786 /** 787 * Get the garbage collection statistics. 788 * 789 * @returns { GcStats } Returns garbage collection statistics. 790 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 791 * @since 12 792 */ 793 function getVMRuntimeStats(): GcStats; 794 795 /** 796 * Get the garbage collection statistics by statistical item. 797 * 798 * @param { string } item - statistical item. 799 * @returns { number } Returns garbage collection statistics. 800 * @throws { BusinessError } 401 - Possible causes: 801 * 1. Invalid parameter, a string parameter required. 802 * 2. Invalid parameter, unknown property. 803 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 804 * @since 12 805 */ 806 function getVMRuntimeStat(item: string): number; 807 808 /** 809 * Set the resource limitation of application.Please note that this function is only valid 810 * when the developer options switch of setting is turned on. 811 * 812 * @param { string } type - resource type. It could be pss_memory、js_heap、fd、or thread. 813 * @param { number } value - For different resource type, values could have different meaning: 814 * 1.For pss_memory, it means the baseline PSS memory size for the application, 815 * system memory control will be triggered if exceed the value too much. 816 * 2.For js_heap, it means the percentage of the used JS heap memory to the maximum limit exceed 817 * which heap dump will be triggered if enableDebugLog set as true, it can be set between 85 and 95. 818 * 3.For fd, it means the maximum fd number can be opened. 819 * 4.For thread, it means the maximum thread number can be created. 820 * @param { boolean } enableDebugLog - Whether to enable external debug log. Default is false, pls make sure set 821 * it as true only in gray release because collecting debug log will cost too much cpu or memory. 822 * @throws { BusinessError } 401 - Invalid argument, Possible causes: 823 * 1.The limit parameter is too small 824 * 2.The parameter is not in the specified type 825 * 3.The parameter type error or parameter order error 826 * @throws { BusinessError } 11400104 - Set limit failed due to remote exception 827 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 828 * @atomicservice 829 * @since 12 830 */ 831 function setAppResourceLimit(type: string, value: number, enableDebugLog: boolean): void; 832 833 /** 834 * Judge if the application is in debugged state, including either in arkui layer or native layer debugged state. 835 * 836 * @returns { boolean } true if the application is debugged. 837 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug 838 * @since 12 839 */ 840 function isDebugState(): boolean; 841} 842export default hidebug; 843