Skip to content

Commit bedcb9e

Browse files
authored
Merge pull request #230 from NativeScript/tbozhikov/fix-memory-issue-ios
fix: call GC upon image picking
2 parents 5c809f5 + 941ccdd commit bedcb9e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/imagepicker.ios.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as data_observable from "tns-core-modules/data/observable";
2-
import * as frame from "tns-core-modules/ui/frame";
32
import * as imageAssetModule from "tns-core-modules/image-asset";
43
import { Options, ImagePickerMediaType } from ".";
54
import { View } from "tns-core-modules/ui/core/view/view";
5+
import * as utils from "tns-core-modules/utils/utils";
66

77
const defaultAssetCollectionSubtypes: NSArray<any> = NSArray.arrayWithArray(<any>[
88
PHAssetCollectionSubtype.SmartAlbumRecentlyAdded,
@@ -102,7 +102,13 @@ export class ImagePickerControllerDelegate extends NSObject implements QBImagePi
102102

103103
this._resolve(assets);
104104

105-
imagePickerController.dismissViewControllerAnimatedCompletion(true, null);
105+
imagePickerController.dismissViewControllerAnimatedCompletion(true, () => {
106+
// FIX: possible memory issue when picking images many times.
107+
// Not the best solution, but the only one working for now
108+
// https://github.com/NativeScript/nativescript-imagepicker/issues/222
109+
setTimeout(utils.GC, 200);
110+
});
111+
106112
}
107113

108114
public static ObjCProtocols = [QBImagePickerControllerDelegate];

0 commit comments

Comments
 (0)