Re^2: Is $^M a leftover April Fool?
by BrowserUk (Patriarch) on Jan 06, 2005 at 14:58 UTC
|
Here's a blast from the past. You're right, the description is very straight forward. It just doesn't work.
At least, on the version of perl I was using at the time, and given the near absence of documentation of the 'feature', try as hard as I could, I could see no way of utilising it.
And, noone ever came forward with any sugggestion of how I can use $^M to allow my Perl program to obtain control once the system refuses the process further memory allocation so that I might at least be able to clean up; close filehandles, put out a "Sorry!" message, prevent the system generating a core dump. You know, that sort of practical step that $^M promises to allow.
Hmm. What do you call a feature that cannot be used?
Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
| [reply] |
|
I've not tried it, but I seem to recall it working this way. At the beginning of your program, set $^M to a huge pad string:
BEGIN { $^M = "x" x 65536 }
Then, when you're about to take an "out of memory" hit, Perl starts the normal death mechanism, but first deallocates the $^M variable, hopefully
permitting all your death handlers to do their job, because there's now 64K of breathing room to allocate temps and stuff.
At least, this is what I recall.
| [reply] [d/l] |
|
I think you are correct, the problem is, what would cause my death handlers to be invoked?
What I mean is, if my program can never recieve notification of the impending disaster, how will it know to do clean-up?
From what I could workout, stealing 64k at the top of the program, just means that it runs out of memory 64k earlier than it would have. Then it makes use of the 64k reserve transparently, and then fails when the reserve runs out.
As I said in the original thread, the code is there and does seem to be activated, but from the perspective of my perl script, the result is (more or less) identical because it just fails with 'Out of memory' or a Dr.Watson pop-up, or a core dump depending upon how I have my system configured.
As far as I could work out, there is no way for my script to be notified that the reserve buffer is being used, so it has no way to do anything about it?
Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.
| [reply] |
|
|
|
|
| [reply] [d/l] |
|
|
|
| [reply] |
|
| [reply] |