mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
Merge pull request #673 from Icinga:fix/eventlog_reader_memory_leak
Fix: Memory leak in EventLog fetcher
This commit is contained in:
commit
3a32511685
4 changed files with 35 additions and 0 deletions
|
|
@ -11,6 +11,14 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
|||
|
||||
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/28)
|
||||
|
||||
## 1.11.2 (tbd)
|
||||
|
||||
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/30)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* [#673](https://github.com/Icinga/icinga-powershell-framework/pull/673) Fixes a memory leak while fetching Windows EventLog information by using CLI tools and inside the Hyper-V provide
|
||||
|
||||
## 1.11.1 (2023-11-07)
|
||||
|
||||
[Issues and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/29)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ function Read-IcingaWindowsEventLog()
|
|||
$CollectedEvents += $event;
|
||||
}
|
||||
|
||||
if ($null -ne $IcingaEvents) {
|
||||
$IcingaEvents.Dispose();
|
||||
$IcingaEvents = $null;
|
||||
}
|
||||
|
||||
$CollectedEvents = $CollectedEvents | Sort-Object { $_.TimeCreated };
|
||||
|
||||
foreach ($event in $CollectedEvents) {
|
||||
|
|
@ -71,6 +76,8 @@ function Read-IcingaWindowsEventLog()
|
|||
Write-IcingaConsolePlain -Message '[{0}] {1}' -Objects $event.TimeCreated, $event.Message -ForeColor $ForeColor;
|
||||
}
|
||||
|
||||
$CollectedEvents = $null;
|
||||
|
||||
Start-Sleep -Seconds 1;
|
||||
# Force Icinga for Windows Garbage Collection
|
||||
Optimize-IcingaForWindowsMemory -ClearErrorStack;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ function Show-IcingaEventLogAnalysis()
|
|||
try {
|
||||
[array]$BasicLogArray = Get-WinEvent -ListLog $LogName -ErrorAction Stop;
|
||||
$BasicLogData = $BasicLogArray[0];
|
||||
|
||||
if ($null -ne $BasicLogArray) {
|
||||
$BasicLogArray.Dispose();
|
||||
$BasicLogArray = $null;
|
||||
}
|
||||
} catch {
|
||||
Write-IcingaConsoleError 'Failed to fetch data for EventLog "{0}". Probably this log does not exist.' -Objects $LogName;
|
||||
return;
|
||||
|
|
@ -81,6 +86,11 @@ function Show-IcingaEventLogAnalysis()
|
|||
$LogAnalysis.Minute.Average = [math]::Ceiling($LogAnalysis.Minute.Count / $LogAnalysis.Minute.Entries.Count);
|
||||
}
|
||||
|
||||
if ($null -ne $LogData) {
|
||||
$LogData.Dispose();
|
||||
$LogData = $null;
|
||||
}
|
||||
|
||||
foreach ($value in $LogAnalysis.Day.Entries.Values) {
|
||||
$LogAnalysis.Day.Maximum = Get-IcingaValue -Value $value -Compare $LogAnalysis.Day.Maximum -Maximum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,6 +102,16 @@ function Get-IcingaProviderDataValuesHyperV()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($null -ne $InformationBlackoutTimes) {
|
||||
$InformationBlackoutTimes.Dispose();
|
||||
$InformationBlackoutTimes = $null;
|
||||
}
|
||||
|
||||
if ($null -ne $WarningBlackoutTimes) {
|
||||
$WarningBlackoutTimes.Dispose();
|
||||
$WarningBlackoutTimes = $null;
|
||||
}
|
||||
} catch {
|
||||
Exit-IcingaThrowException -ExceptionType 'Custom' -CustomMessage 'Hyper-V Error' -ExceptionThrown $_.Exception.Message -Force;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue