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 #include "base/process/memory.h" | 5 #include "base/process/memory.h" |
6 | 6 |
7 #include <new> | 7 #include <new> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/process/internal_linux.h" | 12 #include "base/process/internal_linux.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 | 16 |
17 size_t g_oom_size = 0U; | 17 size_t g_oom_size = 0U; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
| 21 #if !defined(OS_ANDROID) |
21 void OnNoMemorySize(size_t size) { | 22 void OnNoMemorySize(size_t size) { |
22 g_oom_size = size; | 23 g_oom_size = size; |
23 | 24 |
24 if (size != 0) | 25 if (size != 0) |
25 LOG(FATAL) << "Out of memory, size = " << size; | 26 LOG(FATAL) << "Out of memory, size = " << size; |
26 LOG(FATAL) << "Out of memory."; | 27 LOG(FATAL) << "Out of memory."; |
27 } | 28 } |
28 | 29 |
29 void OnNoMemory() { | 30 void OnNoMemory() { |
30 OnNoMemorySize(0); | 31 OnNoMemorySize(0); |
31 } | 32 } |
| 33 #endif // !defined(OS_ANDROID) |
32 | 34 |
33 } // namespace | 35 } // namespace |
34 | 36 |
35 #if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) && \ | 37 #if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) && \ |
36 !defined(THREAD_SANITIZER) && !defined(LEAK_SANITIZER) | 38 !defined(THREAD_SANITIZER) && !defined(LEAK_SANITIZER) |
37 | 39 |
38 #if defined(LIBC_GLIBC) && !defined(USE_TCMALLOC) | 40 #if defined(LIBC_GLIBC) && !defined(USE_TCMALLOC) |
39 | 41 |
40 extern "C" { | 42 extern "C" { |
41 void* __libc_malloc(size_t size); | 43 void* __libc_malloc(size_t size); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 int score_len = static_cast<int>(score_str.length()); | 176 int score_len = static_cast<int>(score_str.length()); |
175 return (score_len == file_util::WriteFile(oom_file, | 177 return (score_len == file_util::WriteFile(oom_file, |
176 score_str.c_str(), | 178 score_str.c_str(), |
177 score_len)); | 179 score_len)); |
178 } | 180 } |
179 | 181 |
180 return false; | 182 return false; |
181 } | 183 } |
182 | 184 |
183 } // namespace base | 185 } // namespace base |
OLD | NEW |