mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-04-09 20:27:32 +00:00
* Permanently resolve the memory exhaustion in AMQP
Introduce;
- `MEMORY_PROFILING_DUMP_PATH`
- `MEMORY_PROFILING_TIME_INTERVAL`
environment variables and make `startMemoryProfiler` method more parameterized.
* Fix a leak in HTTP
* Revert "Fix a leak in HTTP"
This reverts commit 9d46820ff3.
* Set maximum AMQP message size to 16MB
* Set `GOGC` to 12800
* Remove some commented out lines and an unnecessary `else if`
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package tap
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
const (
|
|
MemoryProfilingEnabledEnvVarName = "MEMORY_PROFILING_ENABLED"
|
|
MemoryProfilingDumpPath = "MEMORY_PROFILING_DUMP_PATH"
|
|
MemoryProfilingTimeIntervalSeconds = "MEMORY_PROFILING_TIME_INTERVAL"
|
|
MaxBufferedPagesTotalEnvVarName = "MAX_BUFFERED_PAGES_TOTAL"
|
|
MaxBufferedPagesPerConnectionEnvVarName = "MAX_BUFFERED_PAGES_PER_CONNECTION"
|
|
MaxBufferedPagesTotalDefaultValue = 5000
|
|
MaxBufferedPagesPerConnectionDefaultValue = 5000
|
|
)
|
|
|
|
type globalSettings struct {
|
|
filterAuthorities []string
|
|
}
|
|
|
|
var gSettings = &globalSettings{
|
|
filterAuthorities: []string{},
|
|
}
|
|
|
|
func SetFilterAuthorities(ipAddresses []string) {
|
|
gSettings.filterAuthorities = ipAddresses
|
|
}
|
|
|
|
func GetFilterIPs() []string {
|
|
addresses := make([]string, len(gSettings.filterAuthorities))
|
|
copy(addresses, gSettings.filterAuthorities)
|
|
return addresses
|
|
}
|
|
|
|
func GetMaxBufferedPagesTotal() int {
|
|
valueFromEnv, err := strconv.Atoi(os.Getenv(MaxBufferedPagesTotalEnvVarName))
|
|
if err != nil {
|
|
return MaxBufferedPagesTotalDefaultValue
|
|
}
|
|
return valueFromEnv
|
|
}
|
|
|
|
func GetMaxBufferedPagesPerConnection() int {
|
|
valueFromEnv, err := strconv.Atoi(os.Getenv(MaxBufferedPagesPerConnectionEnvVarName))
|
|
if err != nil {
|
|
return MaxBufferedPagesPerConnectionDefaultValue
|
|
}
|
|
return valueFromEnv
|
|
}
|
|
|
|
func GetMemoryProfilingEnabled() bool {
|
|
return os.Getenv(MemoryProfilingEnabledEnvVarName) == "1"
|
|
}
|