Skip to content

Commit

Permalink
fix memory leaks (#424)
Browse files Browse the repository at this point in the history
* the defragmenter was not cleaned up completely after the last fragment

* clone strings from the XCTAttachments object

without cloning them the whole XCTAttachment and XCActivityRecord struct is being kept in memory
  • Loading branch information
dmissmann authored Jul 11, 2024
1 parent 544a5f8 commit dd33eed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ios/dtx_codec/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,19 @@ func (d *Channel) Dispatch(msg Message) {
d.messageDispatcher.Dispatch(msg)
}
delete(d.responseWaiters, msg.Identifier)
delete(d.defragmenters, msg.Identifier)
}
return
}
log.Warn("Received message fragment without first message, dropping it")
delete(d.responseWaiters, msg.Identifier)
delete(d.defragmenters, msg.Identifier)
return
}

d.responseWaiters[msg.Identifier] <- msg
delete(d.responseWaiters, msg.Identifier)
delete(d.defragmenters, msg.Identifier)
return
}
d.messageDispatcher.Dispatch(msg)
Expand Down
9 changes: 5 additions & 4 deletions ios/testmanagerd/testlistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"path/filepath"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -133,12 +134,12 @@ func (t *TestListener) testCaseFinished(testClass string, testMethod string, xcA

file.Write(attachment.Payload)
testCase.Attachments = append(testCase.Attachments, TestAttachment{
Name: attachment.Name,
Name: strings.Clone(attachment.Name),
Timestamp: attachment.Timestamp,
Activity: xcActivityRecord.Title,
Activity: strings.Clone(xcActivityRecord.Title),
Path: attachmentsPath,
Type: xcActivityRecord.ActivityType,
UniformTypeIdentifier: attachment.UniformTypeIdentifier,
Type: strings.Clone(xcActivityRecord.ActivityType),
UniformTypeIdentifier: strings.Clone(attachment.UniformTypeIdentifier),
})
}
}
Expand Down

0 comments on commit dd33eed

Please sign in to comment.