xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:
By default, running out of memory is an untrappable, fatal error. However, if suitably built, Perl can use the contents of $^M as an emergency memory pool after "die()"ing. Suppose that your Perl were compiled with "-DPERL_EMERGENCY_SBRK" and used Perl's malloc. Then $^M = 'a' x (1 << 16); would allocate a 64K buffer for use in an emergency.
But I can't find any excerpt code about this variable. Could someone show code about this? Thanks in advance!UPDATE:
Sadly, $^M is not for usage of global memory as I expect. It's only for a seldom scenario: when perl is out of memory even can't call die signal function to clean up, then if you define $^M already, perl would free $^M first and gain memory to clean up. I didn't try it though, but if you are interested in it, you can refer Is $^M a leftover April Fool? to get more discussion about $^M.
I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How use $^M?
by Fletch (Bishop) on Apr 05, 2021 at 13:35 UTC | |
by LanX (Saint) on Apr 05, 2021 at 14:04 UTC | |
by Fletch (Bishop) on Apr 05, 2021 at 14:40 UTC | |
by Bod (Parson) on Apr 05, 2021 at 21:44 UTC | |
Re: How use $^M?
by Discipulus (Canon) on Apr 05, 2021 at 16:17 UTC | |
Re: How use $^M?
by eyepopslikeamosquito (Archbishop) on Apr 05, 2021 at 23:29 UTC | |
by xiaoyafeng (Deacon) on Apr 06, 2021 at 08:33 UTC | |
Re: How use $^M?
by 1nickt (Canon) on Apr 05, 2021 at 13:44 UTC |