OLD | NEW |
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/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Note: Returns true on Windows 2000 without doing anything. | 24 // Note: Returns true on Windows 2000 without doing anything. |
25 BASE_EXPORT bool EnableLowFragmentationHeap(); | 25 BASE_EXPORT bool EnableLowFragmentationHeap(); |
26 | 26 |
27 // Enables 'terminate on heap corruption' flag. Helps protect against heap | 27 // Enables 'terminate on heap corruption' flag. Helps protect against heap |
28 // overflow. Has no effect if the OS doesn't provide the necessary facility. | 28 // overflow. Has no effect if the OS doesn't provide the necessary facility. |
29 BASE_EXPORT void EnableTerminationOnHeapCorruption(); | 29 BASE_EXPORT void EnableTerminationOnHeapCorruption(); |
30 | 30 |
31 // Turns on process termination if memory runs out. | 31 // Turns on process termination if memory runs out. |
32 BASE_EXPORT void EnableTerminationOnOutOfMemory(); | 32 BASE_EXPORT void EnableTerminationOnOutOfMemory(); |
33 | 33 |
34 #if defined(USE_LINUX_BREAKPAD) | |
35 BASE_EXPORT extern size_t g_oom_size; | |
36 #endif | |
37 | |
38 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
39 // Returns the module handle to which an address belongs. The reference count | 35 // Returns the module handle to which an address belongs. The reference count |
40 // of the module is not incremented. | 36 // of the module is not incremented. |
41 BASE_EXPORT HMODULE GetModuleFromAddress(void* address); | 37 BASE_EXPORT HMODULE GetModuleFromAddress(void* address); |
42 #endif | 38 #endif |
43 | 39 |
44 #if defined(OS_LINUX) || defined(OS_ANDROID) | 40 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 41 BASE_EXPORT extern size_t g_oom_size; |
| 42 |
45 // The maximum allowed value for the OOM score. | 43 // The maximum allowed value for the OOM score. |
46 const int kMaxOomScore = 1000; | 44 const int kMaxOomScore = 1000; |
47 | 45 |
48 // 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 |
49 // 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 |
50 // adjustment is [-1000, 1000], with [0, 1000] being user accessible. | 48 // adjustment is [-1000, 1000], with [0, 1000] being user accessible. |
51 // 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 |
52 // 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 |
53 // translate the given value into [0, 15]. Some aliasing of values | 51 // translate the given value into [0, 15]. Some aliasing of values |
54 // may occur in that case, of course. | 52 // may occur in that case, of course. |
55 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); | 53 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); |
56 #endif | 54 #endif |
57 | 55 |
58 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
59 // Very large images or svg canvases can cause huge mallocs. Skia | 57 // Very large images or svg canvases can cause huge mallocs. Skia |
60 // does tricks on tcmalloc-based systems to allow malloc to fail with | 58 // does tricks on tcmalloc-based systems to allow malloc to fail with |
61 // a NULL rather than hit the oom crasher. This replicates that for | 59 // a NULL rather than hit the oom crasher. This replicates that for |
62 // OSX. | 60 // OSX. |
63 // | 61 // |
64 // IF YOU USE THIS WITHOUT CONSULTING YOUR FRIENDLY OSX DEVELOPER, | 62 // IF YOU USE THIS WITHOUT CONSULTING YOUR FRIENDLY OSX DEVELOPER, |
65 // YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU. | 63 // YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU. |
66 BASE_EXPORT void* UncheckedMalloc(size_t size); | 64 BASE_EXPORT void* UncheckedMalloc(size_t size); |
67 #endif // defined(OS_MACOSX) | 65 #endif // defined(OS_MACOSX) |
68 | 66 |
69 } // namespace base | 67 } // namespace base |
70 | 68 |
71 #endif // BASE_PROCESS_MEMORY_H_ | 69 #endif // BASE_PROCESS_MEMORY_H_ |
OLD | NEW |