| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 | 13 |
| 14 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 15 #include <mach/mach_vm.h> |
| 16 #include "third_party/apple_apsl/malloc.h" |
| 17 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 18 |
| 14 #ifdef PVALLOC_AVAILABLE | 19 #ifdef PVALLOC_AVAILABLE |
| 15 // Build config explicitly tells us whether or not pvalloc is available. | 20 // Build config explicitly tells us whether or not pvalloc is available. |
| 16 #elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC) | 21 #elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC) |
| 17 #define PVALLOC_AVAILABLE 1 | 22 #define PVALLOC_AVAILABLE 1 |
| 18 #else | 23 #else |
| 19 #define PVALLOC_AVAILABLE 0 | 24 #define PVALLOC_AVAILABLE 0 |
| 20 #endif | 25 #endif |
| 21 | 26 |
| 22 namespace base { | 27 namespace base { |
| 23 | 28 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 41 // 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 |
| 42 // 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 |
| 43 // adjustment is [-1000, 1000], with [0, 1000] being user accessible. | 48 // adjustment is [-1000, 1000], with [0, 1000] being user accessible. |
| 44 // 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 |
| 45 // 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 |
| 46 // translate the given value into [0, 15]. Some aliasing of values | 51 // translate the given value into [0, 15]. Some aliasing of values |
| 47 // may occur in that case, of course. | 52 // may occur in that case, of course. |
| 48 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); | 53 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); |
| 49 #endif | 54 #endif |
| 50 | 55 |
| 56 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 57 void DeprotectMallocZone(ChromeMallocZone* default_zone, |
| 58 mach_vm_address_t* reprotection_start, |
| 59 mach_vm_size_t* reprotection_length, |
| 60 vm_prot_t* reprotection_value); |
| 61 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 62 |
| 51 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
| 52 namespace win { | 64 namespace win { |
| 53 | 65 |
| 54 // Custom Windows exception code chosen to indicate an out of memory error. | 66 // Custom Windows exception code chosen to indicate an out of memory error. |
| 55 // See https://msdn.microsoft.com/en-us/library/het71c37.aspx. | 67 // See https://msdn.microsoft.com/en-us/library/het71c37.aspx. |
| 56 // "To make sure that you do not define a code that conflicts with an existing | 68 // "To make sure that you do not define a code that conflicts with an existing |
| 57 // exception code" ... "The resulting error code should therefore have the | 69 // exception code" ... "The resulting error code should therefore have the |
| 58 // highest four bits set to hexadecimal E." | 70 // highest four bits set to hexadecimal E." |
| 59 // 0xe0000008 was chosen arbitrarily, as 0x00000008 is ERROR_NOT_ENOUGH_MEMORY. | 71 // 0xe0000008 was chosen arbitrarily, as 0x00000008 is ERROR_NOT_ENOUGH_MEMORY. |
| 60 const DWORD kOomExceptionCode = 0xe0000008; | 72 const DWORD kOomExceptionCode = 0xe0000008; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 // set to NULL, otherwise it holds the memory address. | 86 // set to NULL, otherwise it holds the memory address. |
| 75 BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedMalloc(size_t size, | 87 BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedMalloc(size_t size, |
| 76 void** result); | 88 void** result); |
| 77 BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedCalloc(size_t num_items, | 89 BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedCalloc(size_t num_items, |
| 78 size_t size, | 90 size_t size, |
| 79 void** result); | 91 void** result); |
| 80 | 92 |
| 81 } // namespace base | 93 } // namespace base |
| 82 | 94 |
| 83 #endif // BASE_PROCESS_MEMORY_H_ | 95 #endif // BASE_PROCESS_MEMORY_H_ |
| OLD | NEW |