diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 18:42:41 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 18:42:41 +0000 |
commit | 9f95844be9cc61d2bf2eaee75080e0da8c4e7c67 (patch) | |
tree | 6e20acc04066a2a4f373a47bbd97f93cf58337ab /base/process_util_unittest_mac.mm | |
parent | a334362a51b53d209855eb2f354ba8db2cb5d1ea (diff) | |
download | chromium_src-9f95844be9cc61d2bf2eaee75080e0da8c4e7c67.zip chromium_src-9f95844be9cc61d2bf2eaee75080e0da8c4e7c67.tar.gz chromium_src-9f95844be9cc61d2bf2eaee75080e0da8c4e7c67.tar.bz2 |
Die on an OOM situation in many more cases.
Continuation of http://codereview.chromium.org/875004 after a revert.
BUG=http://crbug.com/12673
TEST=run out of memory and die
Review URL: http://codereview.chromium.org/1039007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42127 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_unittest_mac.mm')
-rw-r--r-- | base/process_util_unittest_mac.mm | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/base/process_util_unittest_mac.mm b/base/process_util_unittest_mac.mm new file mode 100644 index 0000000..3cd7e16 --- /dev/null +++ b/base/process_util_unittest_mac.mm @@ -0,0 +1,42 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/process_util_unittest_mac.h" + +#import <Cocoa/Cocoa.h> + +@interface PsychoticallyBigObjCObject : NSObject +{ + // On 32 bits, the compiler limits Objective C objects to < 2G in size, and on + // 64 bits, the ObjC2 Runtime Reference says that sizeof(anInstance) is + // constrained to 32 bits. Keep it < 2G for simplicity. + int justUnder2Gigs_[(2U * 1024 * 1024 * 1024 - 1) / sizeof(int)]; +} + +@end + +@implementation PsychoticallyBigObjCObject + +@end + + +namespace base { + +void* AllocateViaCFAllocatorSystemDefault(int32 size) { + return CFAllocatorAllocate(kCFAllocatorSystemDefault, size, 0); +} + +void* AllocateViaCFAllocatorMalloc(int32 size) { + return CFAllocatorAllocate(kCFAllocatorMalloc, size, 0); +} + +void* AllocateViaCFAllocatorMallocZone(int32 size) { + return CFAllocatorAllocate(kCFAllocatorMallocZone, size, 0); +} + +void* AllocatePsychoticallyBigObjCObject() { + return [[PsychoticallyBigObjCObject alloc] init]; +} + +} // namespace base |