From 1734719bd021eea4d100a2fbb877d96dc852ba10 Mon Sep 17 00:00:00 2001 From: kosyloa Date: Mon, 10 Jun 2024 15:17:55 +0200 Subject: [PATCH] fix: leaks in schedule --- DXFeedFramework/Native/Schedule/NativeDay.swift | 2 +- DXFeedFramework/Native/Schedule/NativeSchedule.swift | 6 +++++- DXFeedFramework/Native/Schedule/NativeSession.swift | 2 +- DXFeedFramework/Native/Utils/NativeTimeUtil.swift | 4 ++-- build.gradle | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/DXFeedFramework/Native/Schedule/NativeDay.swift b/DXFeedFramework/Native/Schedule/NativeDay.swift index 2aaa35fd8..71c0232b0 100644 --- a/DXFeedFramework/Native/Schedule/NativeDay.swift +++ b/DXFeedFramework/Native/Schedule/NativeDay.swift @@ -10,6 +10,6 @@ import Foundation class NativeDay: NativeBox { deinit { let thread = currentThread() - _ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler))) + _ = try? ErrorCheck.nativeCall(thread, dxfg_Day_release(thread, native)) } } diff --git a/DXFeedFramework/Native/Schedule/NativeSchedule.swift b/DXFeedFramework/Native/Schedule/NativeSchedule.swift index 82f06009d..2f75f9e7d 100644 --- a/DXFeedFramework/Native/Schedule/NativeSchedule.swift +++ b/DXFeedFramework/Native/Schedule/NativeSchedule.swift @@ -128,6 +128,10 @@ class NativeSchedule { scheduleDay.startTime = try ErrorCheck.nativeCall(thread, dxfg_Day_getStartTime(thread, day)) scheduleDay.endTime = try ErrorCheck.nativeCall(thread, dxfg_Day_getEndTime(thread, day)) let sessions = try ErrorCheck.nativeCall(thread, dxfg_Day_getSessions(thread, day)).value() + defer { + _ = try? ErrorCheck.nativeCall(thread, dxfg_SessionList_release(thread, sessions)) + } + let count = sessions.pointee.size for index in 0.. { deinit { let thread = currentThread() - _ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler))) + _ = try? ErrorCheck.nativeCall(thread, dxfg_Session_release(thread, native)) } } diff --git a/DXFeedFramework/Native/Utils/NativeTimeUtil.swift b/DXFeedFramework/Native/Utils/NativeTimeUtil.swift index be279063a..651b2826c 100644 --- a/DXFeedFramework/Native/Utils/NativeTimeUtil.swift +++ b/DXFeedFramework/Native/Utils/NativeTimeUtil.swift @@ -23,8 +23,8 @@ class NativeTimeUtil { let result = try ErrorCheck.nativeCall(thread, dxfg_TimeFormat_format(thread, timeFormat.native, - value)) - return String(pointee: result) + value)) + return try String(nullable: result).value() } } diff --git a/build.gradle b/build.gradle index a4931e02c..db9de601d 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ repositories { } } -def native_version = '1.1.16' +def native_version = '1.1.18' def name = 'graal-native-sdk' dependencies { implementation(group: 'com.dxfeed', name: "${name}", version: "${native_version}", classifier: 'aarch64-osx', ext: 'zip')