ionic-team / ionic-team/capacitor

[Bug]: Memory leak when calling native function repeatedly

Open
#7,883 2 comments 2 reactions 1 assignee Claimed by @theproducer View on GitHub
platform: ios type: bug
Dominant language
TypeScript
Stars
16.7k
Forks
1.3k
Avg merge
3d 15h
Merged PRs (30d)
10

Description

### Capacitor Version

```
💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/android: 7.0.1
@capacitor/ios: 7.0.1

Installed Dependencies:

@capacitor/android: not installed
@capacitor/cli: 7.0.1
@capacitor/core: 7.0.1
@capacitor/ios: 7.0.1

[success] iOS looking great! 👌
```

### Platforms Affected

- [x] iOS
- [ ] Android
- [ ] Web

### Current Behavior

1. Create a simple plugin with promise-returning function.
2. Implement it on iOS side - make it return a 10mb string
3. Call this function multiple times from JS

If you run this on device, the Safari inspector will report memory being allocated for every call and never garbage collected.

Image

### Expected Behavior

Memory should be garbage collected after each call.

### Project Reproduction

https://github.com/vojto/dbtest

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.