Skip to content

Commit

Permalink
add autoreleasepool in publish
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Oct 20, 2023
1 parent 6b94df8 commit db46e4e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = " Dump localhost:6666 timeandsale,candle YQKNT -p dxfeed.wildcard.enable=true,one_more_prop=abc -t test_tape_ios.txt[format=text] -q"
argument = " Dump demo.dxfeed.com:7300 timeandsale ETH/USD:GDAX -p dxfeed.wildcard.enable=true,one_more_prop=abc -t test_tape_ios.txt[format=text] -q"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = " Dump localhost:6666 TimeAndSale all -p dxfeed.wildcard.enable=true,one_more_prop=abc -t test_tape_ios.txt[format=text] -q"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
Expand Down
28 changes: 15 additions & 13 deletions DXFeedFramework/Native/Feed/NativePublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ class NativePublisher {
}

func publishEvents(events: [MarketEvent]) throws {
let nativeEvents = events.compactMap { event in
try? mapper.toNative(event: event)
}
try autoreleasepool {
let nativeEvents = events.compactMap { event in
try? mapper.toNative(event: event)
}

let nativePointers = ListNative(pointers: nativeEvents)
let listPointer = nativePointers.newList()
let nativePointers = ListNative(pointers: nativeEvents)
let listPointer = nativePointers.newList()

defer {
listPointer.deinitialize(count: 1)
listPointer.deallocate()
nativeEvents.forEach { mapper.releaseNative(native: $0) }
defer {
listPointer.deinitialize(count: 1)
listPointer.deallocate()
nativeEvents.forEach { mapper.releaseNative(native: $0) }
}
let thread = currentThread()
_ = try ErrorCheck.nativeCall(thread, dxfg_DXPublisher_publishEvents(thread,
publisher,
listPointer))
}
let thread = currentThread()
_ = try ErrorCheck.nativeCall(thread, dxfg_DXPublisher_publishEvents(thread,
publisher,
listPointer))
}
}
1 change: 1 addition & 0 deletions Samples/PerfTestCL/DumpCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DumpCommand: ToolsCommand {
}
}()


func execute() {
let address = arguments[1]
let types = arguments[2]
Expand Down

0 comments on commit db46e4e

Please sign in to comment.