| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 SpinLock Partitions::s_initializationLock; | 41 SpinLock Partitions::s_initializationLock; |
| 42 bool Partitions::s_initialized = false; | 42 bool Partitions::s_initialized = false; |
| 43 | 43 |
| 44 PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; | 44 PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; |
| 45 PartitionAllocatorGeneric Partitions::m_bufferAllocator; | 45 PartitionAllocatorGeneric Partitions::m_bufferAllocator; |
| 46 #if !ENABLE(OILPAN) | 46 #if !ENABLE(OILPAN) |
| 47 SizeSpecificPartitionAllocator<3328> Partitions::m_nodeAllocator; | 47 SizeSpecificPartitionAllocator<3328> Partitions::m_nodeAllocator; |
| 48 #endif | 48 #endif |
| 49 SizeSpecificPartitionAllocator<1024> Partitions::m_layoutAllocator; | 49 SizeSpecificPartitionAllocator<1024> Partitions::m_layoutAllocator; |
| 50 HistogramEnumerationFunction Partitions::m_histogramEnumeration = nullptr; | 50 Partitions::ReportPartitionAllocSizeFunction Partitions::m_reportSizeFunction =
nullptr; |
| 51 | 51 |
| 52 void Partitions::initialize(HistogramEnumerationFunction histogramEnumeration) | 52 void Partitions::initialize(ReportPartitionAllocSizeFunction reportSizeFunction) |
| 53 { | 53 { |
| 54 SpinLock::Guard guard(s_initializationLock); | 54 SpinLock::Guard guard(s_initializationLock); |
| 55 | 55 |
| 56 if (!s_initialized) { | 56 if (!s_initialized) { |
| 57 partitionAllocGlobalInit(&Partitions::handleOutOfMemory); | 57 partitionAllocGlobalInit(&Partitions::handleOutOfMemory); |
| 58 m_fastMallocAllocator.init(); | 58 m_fastMallocAllocator.init(); |
| 59 m_bufferAllocator.init(); | 59 m_bufferAllocator.init(); |
| 60 #if !ENABLE(OILPAN) | 60 #if !ENABLE(OILPAN) |
| 61 m_nodeAllocator.init(); | 61 m_nodeAllocator.init(); |
| 62 #endif | 62 #endif |
| 63 m_layoutAllocator.init(); | 63 m_layoutAllocator.init(); |
| 64 m_histogramEnumeration = histogramEnumeration; | 64 m_reportSizeFunction = reportSizeFunction; |
| 65 s_initialized = true; | 65 s_initialized = true; |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 void Partitions::shutdown() | 69 void Partitions::shutdown() |
| 70 { | 70 { |
| 71 SpinLock::Guard guard(s_initializationLock); | 71 SpinLock::Guard guard(s_initializationLock); |
| 72 | 72 |
| 73 // We could ASSERT here for a memory leak within the partition, but it leads | 73 // We could ASSERT here for a memory leak within the partition, but it leads |
| 74 // to very hard to diagnose ASSERTs, so it's best to leave leak checking for | 74 // to very hard to diagnose ASSERTs, so it's best to leave leak checking for |
| (...skipping 17 matching lines...) Expand all Loading... |
| 92 partitionPurgeMemoryGeneric(bufferPartition(), PartitionPurgeDecommitEmptyPa
ges); | 92 partitionPurgeMemoryGeneric(bufferPartition(), PartitionPurgeDecommitEmptyPa
ges); |
| 93 partitionPurgeMemoryGeneric(fastMallocPartition(), PartitionPurgeDecommitEmp
tyPages); | 93 partitionPurgeMemoryGeneric(fastMallocPartition(), PartitionPurgeDecommitEmp
tyPages); |
| 94 #if !ENABLE(OILPAN) | 94 #if !ENABLE(OILPAN) |
| 95 partitionPurgeMemory(nodePartition(), PartitionPurgeDecommitEmptyPages); | 95 partitionPurgeMemory(nodePartition(), PartitionPurgeDecommitEmptyPages); |
| 96 #endif | 96 #endif |
| 97 partitionPurgeMemory(layoutPartition(), PartitionPurgeDecommitEmptyPages); | 97 partitionPurgeMemory(layoutPartition(), PartitionPurgeDecommitEmptyPages); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void Partitions::reportMemoryUsageHistogram() | 100 void Partitions::reportMemoryUsageHistogram() |
| 101 { | 101 { |
| 102 static size_t supportedMaxSizeInMB = 4 * 1024; | |
| 103 static size_t observedMaxSizeInMB = 0; | 102 static size_t observedMaxSizeInMB = 0; |
| 104 | 103 |
| 105 if (!m_histogramEnumeration) | 104 if (!m_reportSizeFunction) |
| 106 return; | 105 return; |
| 107 // We only report the memory in the main thread. | 106 // We only report the memory in the main thread. |
| 108 if (!isMainThread()) | 107 if (!isMainThread()) |
| 109 return; | 108 return; |
| 110 // +1 is for rounding up the sizeInMB. | 109 // +1 is for rounding up the sizeInMB. |
| 111 size_t sizeInMB = Partitions::totalSizeOfCommittedPages() / 1024 / 1024 + 1; | 110 size_t sizeInMB = Partitions::totalSizeOfCommittedPages() / 1024 / 1024 + 1; |
| 112 if (sizeInMB >= supportedMaxSizeInMB) | |
| 113 sizeInMB = supportedMaxSizeInMB - 1; | |
| 114 if (sizeInMB > observedMaxSizeInMB) { | 111 if (sizeInMB > observedMaxSizeInMB) { |
| 115 // Send a UseCounter only when we see the highest memory usage | 112 m_reportSizeFunction(sizeInMB); |
| 116 // we've ever seen. | |
| 117 m_histogramEnumeration("PartitionAlloc.CommittedSize", sizeInMB, support
edMaxSizeInMB); | |
| 118 observedMaxSizeInMB = sizeInMB; | 113 observedMaxSizeInMB = sizeInMB; |
| 119 } | 114 } |
| 120 } | 115 } |
| 121 | 116 |
| 122 void Partitions::dumpMemoryStats(bool isLightDump, PartitionStatsDumper* partiti
onStatsDumper) | 117 void Partitions::dumpMemoryStats(bool isLightDump, PartitionStatsDumper* partiti
onStatsDumper) |
| 123 { | 118 { |
| 124 // Object model and rendering partitions are not thread safe and can be | 119 // Object model and rendering partitions are not thread safe and can be |
| 125 // accessed only on the main thread. | 120 // accessed only on the main thread. |
| 126 ASSERT(isMainThread()); | 121 ASSERT(isMainThread()); |
| 127 | 122 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if (totalUsage >= 64 * 1024 * 1024) | 209 if (totalUsage >= 64 * 1024 * 1024) |
| 215 partitionsOutOfMemoryUsing64M(); | 210 partitionsOutOfMemoryUsing64M(); |
| 216 if (totalUsage >= 32 * 1024 * 1024) | 211 if (totalUsage >= 32 * 1024 * 1024) |
| 217 partitionsOutOfMemoryUsing32M(); | 212 partitionsOutOfMemoryUsing32M(); |
| 218 if (totalUsage >= 16 * 1024 * 1024) | 213 if (totalUsage >= 16 * 1024 * 1024) |
| 219 partitionsOutOfMemoryUsing16M(); | 214 partitionsOutOfMemoryUsing16M(); |
| 220 partitionsOutOfMemoryUsingLessThan16M(); | 215 partitionsOutOfMemoryUsingLessThan16M(); |
| 221 } | 216 } |
| 222 | 217 |
| 223 } // namespace WTF | 218 } // namespace WTF |
| OLD | NEW |