Mercurial > hg > svcore
comparison base/StorageAdviser.cpp @ 415:e37e44681720
* Fix failure to take into account near-OOM situations!
author | Chris Cannam |
---|---|
date | Mon, 09 Jun 2008 16:01:22 +0000 |
parents | 52303ec15cd2 |
children | cff476cfce77 |
comparison
equal
deleted
inserted
replaced
414:c8955c486340 | 415:e37e44681720 |
---|---|
20 | 20 |
21 #include "system/System.h" | 21 #include "system/System.h" |
22 | 22 |
23 #include <iostream> | 23 #include <iostream> |
24 | 24 |
25 //#define DEBUG_STORAGE_ADVISER 1 | 25 #define DEBUG_STORAGE_ADVISER 1 |
26 | 26 |
27 long StorageAdviser::m_discPlanned = 0; | 27 long StorageAdviser::m_discPlanned = 0; |
28 long StorageAdviser::m_memoryPlanned = 0; | 28 long StorageAdviser::m_memoryPlanned = 0; |
29 | 29 |
30 StorageAdviser::Recommendation | 30 StorageAdviser::Recommendation |
83 | 83 |
84 int minmb = minimumSize / 1024 + 1; | 84 int minmb = minimumSize / 1024 + 1; |
85 int maxmb = maximumSize / 1024 + 1; | 85 int maxmb = maximumSize / 1024 + 1; |
86 | 86 |
87 if (memoryFree == -1) memoryStatus = Unknown; | 87 if (memoryFree == -1) memoryStatus = Unknown; |
88 else if (memoryFree < memoryTotal / 3) memoryStatus = Insufficient; | |
88 else if (minmb > (memoryFree * 3) / 4) memoryStatus = Insufficient; | 89 else if (minmb > (memoryFree * 3) / 4) memoryStatus = Insufficient; |
89 else if (maxmb > (memoryFree * 3) / 4) memoryStatus = Marginal; | 90 else if (maxmb > (memoryFree * 3) / 4) memoryStatus = Marginal; |
90 else if (minmb > (memoryFree / 3)) memoryStatus = Marginal; | 91 else if (minmb > (memoryFree / 3)) memoryStatus = Marginal; |
91 else if (memoryTotal == -1 || | 92 else if (memoryTotal == -1 || |
92 minmb > (memoryTotal / 10)) memoryStatus = Marginal; | 93 minmb > (memoryTotal / 10)) memoryStatus = Marginal; |
93 else if (memoryFree < memoryTotal / 4) memoryStatus = Marginal; | |
94 else memoryStatus = Sufficient; | 94 else memoryStatus = Sufficient; |
95 | 95 |
96 if (discFree == -1) discStatus = Unknown; | 96 if (discFree == -1) discStatus = Unknown; |
97 else if (minmb > (discFree * 3) / 4) discStatus = Insufficient; | 97 else if (minmb > (discFree * 3) / 4) discStatus = Insufficient; |
98 else if (maxmb > (discFree / 4)) discStatus = Marginal; | 98 else if (maxmb > (discFree / 4)) discStatus = Marginal; |