It depends on your operating system more than Perl. Linux 2.6.14 introduced the /proc/pid/smaps magic file, which counts up "private" and "shared" memory usage, as well as "clean" and "dirty".
In this case, you want to know the amount of "private, dirty" pages you have. You can use the existing CPAN module Linux::Smaps to read these smaps files.
Comment on Re: Find total "actual" memory usage of forked processes