miniprogram-probe
v0.1.0
Published
[![npm version][npm-version-src]][npm-version-href] [![bundle][bundle-src]][bundle-href] [![JSDocs][jsdocs-src]][jsdocs-href] [![License][license-src]][license-href]
Maintainers
Readme
miniprogram-probe
Usage
miniprogram-probe samples WeChat Mini Program memory on a real Android device.
Requirements
- Node.js and pnpm
- Android device with WeChat installed
- ADB
Install ADB:
- Recommended: install Android Studio, then install Android SDK Platform-Tools from SDK Manager.
- Or download SDK Platform-Tools directly.
On macOS, ADB is usually installed at:
~/Library/Android/sdk/platform-tools/adbIf adb is not found, add it to PATH:
echo 'export PATH="$HOME/Library/Android/sdk/platform-tools:$PATH"' >> ~/.zshrc
source ~/.zshrcEnable USB debugging on the phone, connect it to the computer, then check:
adb devicesThe device status should be device, not unauthorized or offline.
Usage
Install dependencies:
pnpm installList devices:
pnpm start deviceOpen the target Mini Program and keep it in the foreground, then start sampling:
pnpm start watchSet a custom interval and output file:
pnpm start watch --interval 1000 --output outputs/watch.jsonPress Ctrl-C to stop. The CLI keeps writing JSON while sampling and prints the final result when stopped.
Process Selection
WeChat may keep several Mini Program processes alive:
com.tencent.mm:appbrand0
com.tencent.mm:appbrand1
com.tencent.mm:appbrand2The CLI does not guess from appbrand0/1/2. It reads Android Activity state, finds the pid for the current AppBrandUI, then samples that pid with dumpsys meminfo.
To avoid sampling a background leftover process, open the target Mini Program in the foreground before running watch. To verify manually:
adb shell dumpsys window | grep -E 'mCurrentFocus|mFocusedApp'
adb shell dumpsys activity top | grep -A40 'ACTIVITY com.tencent.mm/.plugin.appbrand.ui.AppBrandUI'
adb shell ps -A | grep 'com.tencent.mm:appbrand'Configuration
No config file is required.
Options:
--interval <ms>: sample interval. Default:5000.--output <file>: JSON output path. Default:outputs/miniprogram-probe-watch-<timestamp>.json.
Development
pnpm build
pnpm typecheck
pnpm lint
pnpm testLicense
MIT License © jinghaihan
