| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 namespace WTF { | 37 namespace WTF { |
| 38 | 38 |
| 39 const char* const Partitions::kAllocatedObjectPoolName = | 39 const char* const Partitions::kAllocatedObjectPoolName = |
| 40 "partition_alloc/allocated_objects"; | 40 "partition_alloc/allocated_objects"; |
| 41 | 41 |
| 42 base::subtle::SpinLock Partitions::s_initializationLock; | 42 base::subtle::SpinLock Partitions::s_initializationLock; |
| 43 bool Partitions::s_initialized = false; | 43 bool Partitions::s_initialized = false; |
| 44 | 44 |
| 45 base::PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; | 45 base::PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; |
| 46 base::PartitionAllocatorGeneric Partitions::m_arrayBufferAllocator; |
| 46 base::PartitionAllocatorGeneric Partitions::m_bufferAllocator; | 47 base::PartitionAllocatorGeneric Partitions::m_bufferAllocator; |
| 47 base::SizeSpecificPartitionAllocator<1024> Partitions::m_layoutAllocator; | 48 base::SizeSpecificPartitionAllocator<1024> Partitions::m_layoutAllocator; |
| 48 Partitions::ReportPartitionAllocSizeFunction Partitions::m_reportSizeFunction = | 49 Partitions::ReportPartitionAllocSizeFunction Partitions::m_reportSizeFunction = |
| 49 nullptr; | 50 nullptr; |
| 50 | 51 |
| 51 void Partitions::initialize( | 52 void Partitions::initialize( |
| 52 ReportPartitionAllocSizeFunction reportSizeFunction) { | 53 ReportPartitionAllocSizeFunction reportSizeFunction) { |
| 53 base::subtle::SpinLock::Guard guard(s_initializationLock); | 54 base::subtle::SpinLock::Guard guard(s_initializationLock); |
| 54 | 55 |
| 55 if (!s_initialized) { | 56 if (!s_initialized) { |
| 56 base::PartitionAllocGlobalInit(&Partitions::handleOutOfMemory); | 57 base::PartitionAllocGlobalInit(&Partitions::handleOutOfMemory); |
| 57 m_fastMallocAllocator.init(); | 58 m_fastMallocAllocator.init(); |
| 59 m_arrayBufferAllocator.init(); |
| 58 m_bufferAllocator.init(); | 60 m_bufferAllocator.init(); |
| 59 m_layoutAllocator.init(); | 61 m_layoutAllocator.init(); |
| 60 m_reportSizeFunction = reportSizeFunction; | 62 m_reportSizeFunction = reportSizeFunction; |
| 61 s_initialized = true; | 63 s_initialized = true; |
| 62 } | 64 } |
| 63 } | 65 } |
| 64 | 66 |
| 65 void Partitions::decommitFreeableMemory() { | 67 void Partitions::decommitFreeableMemory() { |
| 66 RELEASE_ASSERT(isMainThread()); | 68 RELEASE_ASSERT(isMainThread()); |
| 67 if (!s_initialized) | 69 if (!s_initialized) |
| 68 return; | 70 return; |
| 69 | 71 |
| 72 PartitionPurgeMemoryGeneric(arrayBufferPartition(), |
| 73 base::PartitionPurgeDecommitEmptyPages); |
| 70 PartitionPurgeMemoryGeneric(bufferPartition(), | 74 PartitionPurgeMemoryGeneric(bufferPartition(), |
| 71 base::PartitionPurgeDecommitEmptyPages); | 75 base::PartitionPurgeDecommitEmptyPages); |
| 72 PartitionPurgeMemoryGeneric(fastMallocPartition(), | 76 PartitionPurgeMemoryGeneric(fastMallocPartition(), |
| 73 base::PartitionPurgeDecommitEmptyPages); | 77 base::PartitionPurgeDecommitEmptyPages); |
| 74 PartitionPurgeMemory(layoutPartition(), | 78 PartitionPurgeMemory(layoutPartition(), |
| 75 base::PartitionPurgeDecommitEmptyPages); | 79 base::PartitionPurgeDecommitEmptyPages); |
| 76 } | 80 } |
| 77 | 81 |
| 78 void Partitions::reportMemoryUsageHistogram() { | 82 void Partitions::reportMemoryUsageHistogram() { |
| 79 static size_t observedMaxSizeInMB = 0; | 83 static size_t observedMaxSizeInMB = 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 94 void Partitions::dumpMemoryStats( | 98 void Partitions::dumpMemoryStats( |
| 95 bool isLightDump, | 99 bool isLightDump, |
| 96 base::PartitionStatsDumper* partitionStatsDumper) { | 100 base::PartitionStatsDumper* partitionStatsDumper) { |
| 97 // Object model and rendering partitions are not thread safe and can be | 101 // Object model and rendering partitions are not thread safe and can be |
| 98 // accessed only on the main thread. | 102 // accessed only on the main thread. |
| 99 DCHECK(isMainThread()); | 103 DCHECK(isMainThread()); |
| 100 | 104 |
| 101 decommitFreeableMemory(); | 105 decommitFreeableMemory(); |
| 102 PartitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc", isLightDump, | 106 PartitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc", isLightDump, |
| 103 partitionStatsDumper); | 107 partitionStatsDumper); |
| 108 PartitionDumpStatsGeneric(arrayBufferPartition(), "array_buffer", isLightDump, |
| 109 partitionStatsDumper); |
| 104 PartitionDumpStatsGeneric(bufferPartition(), "buffer", isLightDump, | 110 PartitionDumpStatsGeneric(bufferPartition(), "buffer", isLightDump, |
| 105 partitionStatsDumper); | 111 partitionStatsDumper); |
| 106 PartitionDumpStats(layoutPartition(), "layout", isLightDump, | 112 PartitionDumpStats(layoutPartition(), "layout", isLightDump, |
| 107 partitionStatsDumper); | 113 partitionStatsDumper); |
| 108 } | 114 } |
| 109 | 115 |
| 110 static NEVER_INLINE void partitionsOutOfMemoryUsing2G() { | 116 static NEVER_INLINE void partitionsOutOfMemoryUsing2G() { |
| 111 size_t signature = 2UL * 1024 * 1024 * 1024; | 117 size_t signature = 2UL * 1024 * 1024 * 1024; |
| 112 base::debug::Alias(&signature); | 118 base::debug::Alias(&signature); |
| 113 OOM_CRASH(); | 119 OOM_CRASH(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 if (totalUsage >= 64 * 1024 * 1024) | 186 if (totalUsage >= 64 * 1024 * 1024) |
| 181 partitionsOutOfMemoryUsing64M(); | 187 partitionsOutOfMemoryUsing64M(); |
| 182 if (totalUsage >= 32 * 1024 * 1024) | 188 if (totalUsage >= 32 * 1024 * 1024) |
| 183 partitionsOutOfMemoryUsing32M(); | 189 partitionsOutOfMemoryUsing32M(); |
| 184 if (totalUsage >= 16 * 1024 * 1024) | 190 if (totalUsage >= 16 * 1024 * 1024) |
| 185 partitionsOutOfMemoryUsing16M(); | 191 partitionsOutOfMemoryUsing16M(); |
| 186 partitionsOutOfMemoryUsingLessThan16M(); | 192 partitionsOutOfMemoryUsingLessThan16M(); |
| 187 } | 193 } |
| 188 | 194 |
| 189 } // namespace WTF | 195 } // namespace WTF |
| OLD | NEW |