mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(ios): force release of nsdata after saving image (#9177)
gc isn't cleaning up this fast enough when used in a loop e.g https://github.com/NativeScript/plugins/issues/71
This commit is contained in:
@@ -7,7 +7,7 @@ import { Color } from '../color';
|
||||
|
||||
// Types.
|
||||
import { path as fsPath, knownFolders } from '../file-system';
|
||||
import { isFileOrResourcePath, RESOURCE_PREFIX, layout } from '../utils';
|
||||
import { isFileOrResourcePath, RESOURCE_PREFIX, layout, releaseNativeObject } from '../utils';
|
||||
|
||||
import { getScaledDimensions } from './image-source-common';
|
||||
|
||||
@@ -311,7 +311,10 @@ export class ImageSource implements ImageSourceDefinition {
|
||||
|
||||
const data = getImageData(this.ios, format, quality);
|
||||
if (data) {
|
||||
return NSFileManager.defaultManager.createFileAtPathContentsAttributes(path, data, null);
|
||||
const result = NSFileManager.defaultManager.createFileAtPathContentsAttributes(path, data, null);
|
||||
// release native memory earlier
|
||||
releaseNativeObject(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user