Commit 9b042dd2 authored by Eugene But's avatar Eugene But Committed by Commit Bot

[ios] Speculative fix for StartLeakingMemory function

StartLeakingMemory leaks memory by repeatedly allocating memory using
operator new. This causes UTE in debug Chromium build, but not in
release Chrome build.

It's possible that release build has some optimization that throw away
memory allocation, so this CL adds allocated memory to NSArray<NSData*>
container to ensure the leak.

Bug: 1103752
Change-Id: I162250621bfbded39145e594ec135b4bf46261ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368145
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Auto-Submit: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801057}
parent 02c72f38
...@@ -33,8 +33,16 @@ namespace { ...@@ -33,8 +33,16 @@ namespace {
// Rapidly starts leaking memory by 10MB blocks. // Rapidly starts leaking memory by 10MB blocks.
void StartLeakingMemory() { void StartLeakingMemory() {
int* leak = new int[10 * 1024 * 1024]; static NSMutableArray* memory = nil;
ALLOW_UNUSED_LOCAL(leak); if (!memory)
memory = [[NSMutableArray alloc] init];
// Store block of memory into NSArray to ensure that compiler does not throw
// away unused code.
NSUInteger leak_size = 10 * 1024 * 1024;
int* leak = new int[leak_size];
[memory addObject:[NSData dataWithBytes:leak length:leak_size]];
base::ThreadPool::PostTask(FROM_HERE, base::BindOnce(&StartLeakingMemory)); base::ThreadPool::PostTask(FROM_HERE, base::BindOnce(&StartLeakingMemory));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment