Chromium Code Reviews| Index: base/process/memory.h |
| diff --git a/base/process/memory.h b/base/process/memory.h |
| index e6696cb8a708748a7b9b5724328d5f87c396f3ac..53955e1ba7e69d535abb7360e5c4440404ea6a71 100644 |
| --- a/base/process/memory.h |
| +++ b/base/process/memory.h |
| @@ -14,6 +14,12 @@ |
| #include <windows.h> |
| #endif |
| +#if defined(USE_TCMALLOC) |
| +extern "C" { |
| +typedef void* (*tc_malloc_skip_new_handler_function)(size_t size); |
| +} |
| +#endif |
| + |
| namespace base { |
| // Enables low fragmentation heap (LFH) for every heaps of this process. This |
| @@ -53,17 +59,28 @@ const int kMaxOomScore = 1000; |
| BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); |
| #endif |
| +// Special allocator functions for callers that want to check for OOM. |
| +// These will not abort if the allocation fails even if |
| +// EnableTerminationOnOutOfMemory has been called. |
| +// This can be useful for huge and/or unpredictable size memory allocations. |
| +// Return value tells whether the allocation succeed. If it fails |result| is |
| +// set to NULL, otherwise it holds the memory address. |
|
jln (very slow on Chromium)
2014/01/29 01:34:35
Could you add a comment along the lines of: "Pleas
|
| +BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedMalloc(size_t size, |
| + void** result); |
| +BASE_EXPORT WARN_UNUSED_RESULT bool UncheckedCalloc(size_t num_items, |
| + size_t size, |
| + void** result); |
| + |
| +// FIXME: make Skia use the new interface and remove these. |
|
willchan no longer on Chromium
2014/01/16 01:30:05
Nit: Please use TODO(username). Doesn't mean you h
|
| #if defined(OS_MACOSX) |
| -// Very large images or svg canvases can cause huge mallocs. Skia |
| -// does tricks on tcmalloc-based systems to allow malloc to fail with |
| -// a NULL rather than hit the oom crasher. This replicates that for |
| -// OSX. |
| -// |
| -// IF YOU USE THIS WITHOUT CONSULTING YOUR FRIENDLY OSX DEVELOPER, |
| -// YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU. |
| BASE_EXPORT void* UncheckedMalloc(size_t size); |
| BASE_EXPORT void* UncheckedCalloc(size_t num_items, size_t size); |
| -#endif // defined(OS_MACOSX) |
| +#endif |
| + |
| +#if defined(USE_TCMALLOC) |
| +BASE_EXPORT void SetTCMallocSkipNewHandlerFunction( |
| + tc_malloc_skip_new_handler_function function); |
| +#endif |
| } // namespace base |