M
Maja
Greetings,
/var/adm/wtmp files were getting out of hand
and I wanted to filter the file rather than zeroing it out.
I found some code that would only keep the last x days
but it required creating a temporary file in /tmp
and then copying it back to /var/adm. I rewrote the code
to load the contents of the wtmp file into memory and then
write the filtered records in memory directly back to /var/adm/wtmp,
eliminating the need for a temporary file.
This worked great until I encountered a wtmp file that was
370 MB. malloc fails setting errno to ENOMEM (not enough
storage space). My system has 16GB of memory and 9GB of paging
(33% used). So, I should have plenty of memory.
My question: is there a workaround for this type of malloc error.
Thanks,
Maja
/var/adm/wtmp files were getting out of hand
and I wanted to filter the file rather than zeroing it out.
I found some code that would only keep the last x days
but it required creating a temporary file in /tmp
and then copying it back to /var/adm. I rewrote the code
to load the contents of the wtmp file into memory and then
write the filtered records in memory directly back to /var/adm/wtmp,
eliminating the need for a temporary file.
This worked great until I encountered a wtmp file that was
370 MB. malloc fails setting errno to ENOMEM (not enough
storage space). My system has 16GB of memory and 9GB of paging
(33% used). So, I should have plenty of memory.
My question: is there a workaround for this type of malloc error.
Thanks,
Maja