mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
System Module: fix stupid out of memory detection bug
This commit is contained in:
parent
24cd0c8bff
commit
8f77d07119
@ -389,25 +389,24 @@ static void updateSystemAlarms()
|
||||
EventStats evStats;
|
||||
SystemStatsGet(&stats);
|
||||
|
||||
// Check heap
|
||||
if (stats.HeapRemaining < HEAP_LIMIT_CRITICAL) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_OUTOFMEMORY, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
} else if (stats.HeapRemaining < HEAP_LIMIT_WARNING) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_OUTOFMEMORY, SYSTEMALARMS_ALARM_WARNING);
|
||||
} else {
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_OUTOFMEMORY);
|
||||
}
|
||||
|
||||
// Check heap, IRQ stack and malloc failures
|
||||
if ( mallocFailed
|
||||
|| (stats.HeapRemaining < HEAP_LIMIT_CRITICAL)
|
||||
#if !defined(ARCH_POSIX) && !defined(ARCH_WIN32) && defined(CHECK_IRQ_STACK)
|
||||
// Check IRQ stack
|
||||
if (stats.IRQStackRemaining < IRQSTACK_LIMIT_CRITICAL) {
|
||||
|| (stats.IRQStackRemaining < IRQSTACK_LIMIT_CRITICAL)
|
||||
#endif
|
||||
) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_OUTOFMEMORY, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
} else if (stats.IRQStackRemaining < IRQSTACK_LIMIT_WARNING) {
|
||||
} else if (
|
||||
(stats.HeapRemaining < HEAP_LIMIT_WARNING)
|
||||
#if !defined(ARCH_POSIX) && !defined(ARCH_WIN32) && defined(CHECK_IRQ_STACK)
|
||||
|| (stats.IRQStackRemaining < IRQSTACK_LIMIT_WARNING)
|
||||
#endif
|
||||
) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_OUTOFMEMORY, SYSTEMALARMS_ALARM_WARNING);
|
||||
} else {
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_OUTOFMEMORY);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check CPU load
|
||||
if (stats.CPULoad > CPULOAD_LIMIT_CRITICAL) {
|
||||
@ -425,13 +424,6 @@ static void updateSystemAlarms()
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_STACKOVERFLOW);
|
||||
}
|
||||
|
||||
// Check for malloc failures
|
||||
if (mallocFailed) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_OUTOFMEMORY, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
} else {
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_OUTOFMEMORY);
|
||||
}
|
||||
|
||||
#if defined(PIOS_INCLUDE_SDCARD)
|
||||
// Check for SD card
|
||||
if (PIOS_SDCARD_IsMounted() == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user