-sub _memory_usage_is_too_high {
- return undef unless $::lx_office_conf{system};
-
- my %limits = (
- rss => _parse_number_with_unit($::lx_office_conf{system}->{memory_limit_rss}),
- size => _parse_number_with_unit($::lx_office_conf{system}->{memory_limit_vsz}),
- );
-
- # $::lxdebug->dump(0, "limits", \%limits);
-
- return undef unless $limits{rss} || $limits{vsz};
-
- my %usage;
-
- my $in = IO::File->new("/proc/$$/status", "r") or return undef;
-
- while (<$in>) {
- chomp;
- $usage{lc $1} = _parse_number_with_unit($2) if m{^ vm(rss|size): \s* (\d+ \s* [kmg]b) \s* $}ix;
- }
-
- $in->close;
-
- # $::lxdebug->dump(0, "usage", \%usage);
-
- foreach my $type (keys %limits) {
- next if !$limits{$type};
- next if $limits{$type} >= ($usage{$type} // 0);
-
- $::lxdebug->message(LXDebug::WARN(), "Exiting due to memory size limit reached for type '${type}': limit " . $limits{$type} . " bytes, usage " . $usage{$type} . " bytes");
-
- return 1;
- }
-
- return 0;
-}