Skip to content

Commit e002d72

Browse files
authored
fix(ios): force release of nsdata after saving image (NativeScript#9177)
gc isn't cleaning up this fast enough when used in a loop e.g NativeScript/plugins#71
1 parent 79a5fc8 commit e002d72

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/core/image-source/index.ios.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Color } from '../color';
77

88
// Types.
99
import { path as fsPath, knownFolders } from '../file-system';
10-
import { isFileOrResourcePath, RESOURCE_PREFIX, layout } from '../utils';
10+
import { isFileOrResourcePath, RESOURCE_PREFIX, layout, releaseNativeObject } from '../utils';
1111

1212
import { getScaledDimensions } from './image-source-common';
1313

@@ -311,7 +311,10 @@ export class ImageSource implements ImageSourceDefinition {
311311

312312
const data = getImageData(this.ios, format, quality);
313313
if (data) {
314-
return NSFileManager.defaultManager.createFileAtPathContentsAttributes(path, data, null);
314+
const result = NSFileManager.defaultManager.createFileAtPathContentsAttributes(path, data, null);
315+
// release native memory earlier
316+
releaseNativeObject(data);
317+
return result;
315318
}
316319

317320
return false;

0 commit comments

Comments
 (0)