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

Side by Side Diff: base/process/memory.h

Issue 55333002: Make possible to check memory allocations inside chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #ifndef BASE_PROCESS_MEMORY_H_ 5 #ifndef BASE_PROCESS_MEMORY_H_
6 #define BASE_PROCESS_MEMORY_H_ 6 #define BASE_PROCESS_MEMORY_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/process/process_handle.h" 10 #include "base/process/process_handle.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will 46 // This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will
47 // prefer to kill certain process types over others. The range for the 47 // prefer to kill certain process types over others. The range for the
48 // adjustment is [-1000, 1000], with [0, 1000] being user accessible. 48 // adjustment is [-1000, 1000], with [0, 1000] being user accessible.
49 // If the Linux system doesn't support the newer oom_score_adj range 49 // If the Linux system doesn't support the newer oom_score_adj range
50 // of [0, 1000], then we revert to using the older oom_adj, and 50 // of [0, 1000], then we revert to using the older oom_adj, and
51 // translate the given value into [0, 15]. Some aliasing of values 51 // translate the given value into [0, 15]. Some aliasing of values
52 // may occur in that case, of course. 52 // may occur in that case, of course.
53 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); 53 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score);
54 #endif 54 #endif
55 55
56 #if defined(OS_MACOSX) 56 // Special allocator functions for callers that want to check for OOM.
57 // Very large images or svg canvases can cause huge mallocs. Skia 57 // These will not abort if the allocation fails even if
58 // does tricks on tcmalloc-based systems to allow malloc to fail with 58 // EnableTerminationOnOutOfMemory has been called.
59 // a NULL rather than hit the oom crasher. This replicates that for 59 // This can be useful for huge and/or unpredicteble size memory allocatios.
Ken Russell (switch to Gerrit) 2013/10/31 22:12:48 typos: unpredictable, allocations
60 // OSX.
61 //
62 // IF YOU USE THIS WITHOUT CONSULTING YOUR FRIENDLY OSX DEVELOPER,
63 // YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU.
64 BASE_EXPORT void* UncheckedMalloc(size_t size); 60 BASE_EXPORT void* UncheckedMalloc(size_t size);
65 BASE_EXPORT void* UncheckedCalloc(size_t num_items, size_t size); 61 BASE_EXPORT void* UncheckedCalloc(size_t num_items, size_t size);
66 #endif // defined(OS_MACOSX)
67 62
68 } // namespace base 63 } // namespace base
69 64
70 #endif // BASE_PROCESS_MEMORY_H_ 65 #endif // BASE_PROCESS_MEMORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698