Subject: | memory consumption in BSD::devstat |
Im using BSD::Devstat in a while loop to retrieve disk statistics for a long period of time.
The module does not have any get method so every loop I need to make a new object to retrieve the new stats. This leads to a continuous memory consumption for my perl process.
Can you consider to:
1. Add a new get method for BSD::devstat that we could create one object and then simple
call get() every loop ?
2. Look and check if there are no memory leaks within the .xs code when doing while(1)
continuous loop.
See how it does look:
1. Starting using RES=5688K
last pid: 80180; load averages: 0.24, 0.22, 0.24 up 14+18:12:35 16:00:21
24 processes: 1 running, 23 sleeping
CPU: 0.5% user, 0.0% nice, 0.5% system, 0.0% interrupt, 99.1% idle
Mem: 14M Active, 11M Inact, 663M Wired, 13M Cache, 109M Buf, 262M Free
ARC: 428M Total, 224M MFU, 99M MRU, 16K Anon, 16M Header, 88M Other
Swap: 2048M Total, 16M Used, 2032M Free
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
80180 sdr 1 20 0 32824K 5688K pause 0:00 0.00% perl
After 1.5 minutes: RES=8824K
2. last pid: 80181; load averages: 0.23, 0.22, 0.24 up 14+18:13:33 16:01:19
24 processes: 1 running, 23 sleeping
CPU: 1.4% user, 0.0% nice, 0.0% system, 0.0% interrupt, 98.6% idle
Mem: 17M Active, 11M Inact, 663M Wired, 13M Cache, 109M Buf, 259M Free
ARC: 428M Total, 224M MFU, 99M MRU, 16K Anon, 16M Header, 88M Other
Swap: 2048M Total, 16M Used, 2032M Free
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
80180 sdr 1 20 0 36920K 8824K nanslp 0:00 0.00% perl
Im running the recorder on a very aggressive interval time to simulate this bug.
Simple code to repeat:
use strict;
use warnings;
use BSD::devstat;
my $count = 0;
### MAIN BODY
while (1) {
# get new devstats
my $bds1 = BSD::devstat->new();
$count++;
### Interval
sleep 1;
}