mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1227914: TraceLogger - Limit the memory tracelogger can take, r=bbouvier
This commit is contained in:
parent
8eae746367
commit
83a7889f1f
@ -130,6 +130,9 @@ TLTextIdIsTreeEvent(uint32_t id)
|
||||
id >= TraceLogger_Last;
|
||||
}
|
||||
|
||||
// The maximum amount of ram memory a continuous space structure can take (in bytes).
|
||||
static const uint32_t CONTINUOUSSPACE_LIMIT = 200 * 1024 * 1024;
|
||||
|
||||
template <class T>
|
||||
class ContinuousSpace {
|
||||
T* data_;
|
||||
@ -194,10 +197,15 @@ class ContinuousSpace {
|
||||
return true;
|
||||
|
||||
uint32_t nCapacity = capacity_ * 2;
|
||||
if (size_ + count > nCapacity)
|
||||
if (size_ + count > nCapacity || nCapacity * sizeof(T) > CONTINUOUSSPACE_LIMIT) {
|
||||
nCapacity = size_ + count;
|
||||
T* entries = (T*) js_realloc(data_, nCapacity * sizeof(T));
|
||||
|
||||
// Limit the size of a continuous buffer.
|
||||
if (nCapacity * sizeof(T) > CONTINUOUSSPACE_LIMIT)
|
||||
return false;
|
||||
}
|
||||
|
||||
T* entries = (T*) js_realloc(data_, nCapacity * sizeof(T));
|
||||
if (!entries)
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user