Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: base/process_util_unittest_mac.mm

Issue 1039007: Die on an OOM situation in many more cases.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« base/process_util_mac.mm ('K') | « base/process_util_unittest_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/process_util_unittest_mac.h" 5 #include "base/process_util_unittest_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 @interface PsychoticallyBigObjCObject : NSObject 9 @interface PsychoticallyBigObjCObject : NSObject
10 { 10 {
11 #if __LP64__ 11 // On 32 bits, the compiler limits Objective C objects to < 2G in size, and on
12 // On 64 bits, Objective C objects have no size limit that I can find. 12 // 64 bits, the ObjC2 Runtime Reference says that sizeof(anInstance) is
13 int tooBigToCount_[0xF000000000000000U / sizeof(int)]; 13 // constrained to 32 bits. Keep it < 2G for simplicity.
14 #else
15 // On 32 bits, Objective C objects must be < 2G in size.
16 int justUnder2Gigs_[(2U * 1024 * 1024 * 1024 - 1) / sizeof(int)]; 14 int justUnder2Gigs_[(2U * 1024 * 1024 * 1024 - 1) / sizeof(int)];
17 #endif
18 } 15 }
19 16
20 @end 17 @end
21 18
22 @implementation PsychoticallyBigObjCObject 19 @implementation PsychoticallyBigObjCObject
23 20
24 @end 21 @end
25 22
26 23
27 namespace base { 24 namespace base {
28 25
29 void* AllocateViaCFAllocatorSystemDefault(int32 size) { 26 void* AllocateViaCFAllocatorSystemDefault(int32 size) {
30 return CFAllocatorAllocate(kCFAllocatorSystemDefault, size, 0); 27 return CFAllocatorAllocate(kCFAllocatorSystemDefault, size, 0);
31 } 28 }
32 29
33 void* AllocateViaCFAllocatorMalloc(int32 size) { 30 void* AllocateViaCFAllocatorMalloc(int32 size) {
34 return CFAllocatorAllocate(kCFAllocatorMalloc, size, 0); 31 return CFAllocatorAllocate(kCFAllocatorMalloc, size, 0);
35 } 32 }
36 33
37 void* AllocateViaCFAllocatorMallocZone(int32 size) { 34 void* AllocateViaCFAllocatorMallocZone(int32 size) {
38 return CFAllocatorAllocate(kCFAllocatorMallocZone, size, 0); 35 return CFAllocatorAllocate(kCFAllocatorMallocZone, size, 0);
39 } 36 }
40 37
41 void* AllocatePsychoticallyBigObjCObject() { 38 void* AllocatePsychoticallyBigObjCObject() {
42 return [[PsychoticallyBigObjCObject alloc] init]; 39 return [[PsychoticallyBigObjCObject alloc] init];
43 } 40 }
44 41
45 } // namespace base 42 } // namespace base
OLDNEW
« base/process_util_mac.mm ('K') | « base/process_util_unittest_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698