diff options
author | Patrick Luby <patrick.luby@collabora.com> | 2023-04-17 19:30:14 -0400 |
---|---|---|
committer | Patrick Luby <patrick.luby@collabora.com> | 2023-04-17 19:30:14 -0400 |
commit | cf117b05111ac260c1f0d8ccba5fed59f08dc933 (patch) | |
tree | a79eb316ebdd631c5ecf19b102974546e89514b9 | |
parent | Fix assert failure when running "My Mac (Designed for iPad)" in Xcode (diff) | |
download | online-ios-22-05-run-on-macos.tar.gz online-ios-22-05-run-on-macos.zip |
Related to issue #5876: don't autorelease large NSStrings
ios-22-05-run-on-macos
The +[NSString string...] selectors won't be released until
an enclosing autorelease pool is released. But since we use
ARC, we don't know where the compiler has inserted the
autorelease pool so JS messages may not be released until
after a very long time potentially causing an out of memory
crash. So, use the -[[NSString alloc] init...] selectors
instead.
Signed-off-by: Patrick Luby <patrick.luby@collabora.com>
Change-Id: Iff0be8ee5b322347e746dc030948b82d117c43a1
-rw-r--r-- | ios/Mobile/CODocument.mm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ios/Mobile/CODocument.mm b/ios/Mobile/CODocument.mm index f27d9cbc19..2fd47c3e24 100644 --- a/ios/Mobile/CODocument.mm +++ b/ios/Mobile/CODocument.mm @@ -149,7 +149,15 @@ static std::atomic<unsigned> appDocIdCounter(1); data.push_back(0); - NSString *js = [NSString stringWithUTF8String:data.data()]; + // Related to issue #5876: don't autorelease large NSStrings + // The +[NSString string...] selectors won't be released until + // an enclosing autorelease pool is released. But since we use + // ARC, we don't know where the compiler has inserted the + // autorelease pool so JS messages may not be released until + // after a very long time potentially causing an out of memory + // crash. So, use the -[[NSString alloc] init...] selectors + // instead. + NSString *js = [[NSString alloc] initWithUTF8String:data.data()]; if (!js) { char outBuf[length + 1]; memcpy(outBuf, buffer, length); |