This project demonstrates a potential memory leak when repeatedly passing messages between native code and JavaScript using a Capacitor plugin.
- Install dependencies in this project:
pnpm install- Build and sync the project:
pnpm run build && npx cap sync- Run the iOS app on a real device (not a simulator)
- Open Safari
- In the Develop menu (you may need to enable developer tools in Safari preferences), select your device and open the website inspector
- Go into Timelines tab. Unselect all tools, except for "Memory"
- Start recording
- Click the "Test Echo Plugin" button
The app will:
- Send 30 messages from native to JavaScript
- Wait 2 seconds between each message
- Display a counter of received messages
You should observe:
- The memory usage growing over time
- Memory not being properly garbage collected
- A counter incrementing from 1 to 30 as messages are received
This demonstrates a potential memory leak in the bridge between native code and JavaScript when passing frequent messages.