• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 * This module provides the capability to monitor leakage of JS objects.
23 *
24 * @namespace jsLeakWatcher
25 * @syscap SystemCapability.HiviewDFX.HiChecker
26 * @since 12
27 */
28declare namespace jsLeakWatcher {
29  /**
30   * Enable or disable jsLeakWatcher.
31   *
32   * @param { boolean } isEnable - True is enable jsLeakWatcher, false is disable jsLeakWatcher.
33   * @syscap SystemCapability.HiviewDFX.HiChecker
34   * @since 12
35   */
36  function enable(isEnable: boolean): void;
37
38  /**
39   * Register an object that needs to be monitored.
40   *
41   * @param { object } obj - Object being monitored.
42   * @param { string } msg - Customized object information.
43   * @syscap SystemCapability.HiviewDFX.HiChecker
44   * @since 12
45   */
46  function watch(obj: object, msg: string): void;
47
48  /**
49   * Check suspected leaked objects.
50   *
51   * @returns { string } List of suspected leaked objects in JSON format.
52   * @syscap SystemCapability.HiviewDFX.HiChecker
53   * @since 12
54   */
55   function check(): string;
56
57  /**
58   * Dump leak list and heap snapshot.
59   *
60   * @param { string } filePath - Directory for exporting files.
61   * @returns { Array<string> } The array of exported results, index 0 is leakListFileName, index 1 is heapSnapShotFileName.
62   * @throws { BusinessError } 401 - Parameter error. The filepath is invalid.
63   * @syscap SystemCapability.HiviewDFX.HiChecker
64   * @since 12
65   */
66  function dump(filePath: string): Array<string>;
67}
68export default jsLeakWatcher;
69