niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Not Unix » VMS » vmsperl
[Fwd: Re: How to find memory leak?]
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Thomas Pfau
*nix forums beginner


Joined: 02 Dec 2005
Posts: 7

PostPosted: Tue Feb 28, 2006 11:33 pm    Post subject: [Fwd: Re: How to find memory leak?] Reply with quote

I had meant to send this to the list but hit 'reply' instead of 'reply
all'...

--
tom_p
pfau@nbpfaus.net -- http://nbpfaus.net/~pfau/
Back to top
Craig A. Berry
*nix forums Guru Wannabe


Joined: 27 May 2005
Posts: 143

PostPosted: Fri Mar 03, 2006 8:24 pm    Post subject: Re: [Fwd: Re: How to find memory leak?] Reply with quote

Thanks. I'm cc'ing Dan Sugalski, who I believe still officially owns VMS::Device and VMS::Queue (and VMS::System et al., which may have similar issues).

At 6:33 PM -0500 2/28/06, Thomas Pfau wrote:
Quote:
I had meant to send this to the list but hit 'reply' instead of 'reply all'...

--
tom_p
pfau@nbpfaus.net -- http://nbpfaus.net/~pfau/


Message-ID: <4404DD6E.9080209@nbpfaus.net
Date: Tue, 28 Feb 2006 18:31:58 -0500
From: Thomas Pfau <pfau@nbpfaus.net
User-Agent: Mozilla Thunderbird 1.0.7 (X11/20060107)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: "Craig A. Berry" <craigberry@mac.com
Subject: Re: How to find memory leak?
References: <43FF9704.5070609@nbpfaus.net> <p06230910c025552fd988@[192.168.40.67]
In-Reply-To: <p06230910c025552fd988@[192.168.40.67]
Content-Type: text/plain; format=flowed
Content-Transfer-Encoding: 7bit

Craig A. Berry wrote:

At 6:30 PM -0500 2/24/06, Thomas Pfau wrote:

What facilities are in perl to debug memory allocation issues?



You can run your script with the memory debug option enabled:

$ perl -"Dm" myscript.pl

That will log the memory allocations and deallocations, at least when
Perl's memory API is used.

I had to rebuild my perl since it wasn't built with -DDEBUGGING. Took the opportunity to upgrade from 5.8.6 to 5.8.8.

Anyway, with the new perl, the info above, and a little script to match allocations to deallocations, I managed to find some major leaks in VMS::Device and VMS::Queue. Patches below. These have not been extensively tested but my scripts now run with significantly less leakage. It appears to still leak small amounts of memory but nothing like before.


--- vms-device-0_08/device.xs Mon Dec 18 17:13:04 2000
+++ vms-device-0_09/device.xs Mon Feb 27 13:09:08 2006
@@ -2700,7 +2700,7 @@
/* Did it go OK? */
if (status == SS$_NORMAL) {
/* Looks like it */
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
for (i = 0; i < DevInfoCount; i++) {
switch(OurDataList[i].ReturnType) {
case IS_STRING:
@@ -2854,7 +2854,7 @@
{
HV *AllPurposeHV;
if (!strcmp(InfoName, "DEVCHAR")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
dev_bit_test(AllPurposeHV, REC, BitmapValue);
dev_bit_test(AllPurposeHV, CCL, BitmapValue);
dev_bit_test(AllPurposeHV, TRM, BitmapValue);
@@ -2885,7 +2885,7 @@
dev_bit_test(AllPurposeHV, WCK, BitmapValue);
} else {
if (!strcmp(InfoName, "DEVCHAR2")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
dev_bit_test(AllPurposeHV, CLU, BitmapValue);
dev_bit_test(AllPurposeHV, DET, BitmapValue);
dev_bit_test(AllPurposeHV, RTT, BitmapValue);
@@ -2915,7 +2915,7 @@
dev_bit_test(AllPurposeHV, NOFE, BitmapValue);
} else {
if (!strcmp(InfoName, "STS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
ucb_bit_test(AllPurposeHV, TIM, BitmapValue)
ucb_bit_test(AllPurposeHV, INT, BitmapValue)
ucb_bit_test(AllPurposeHV, ERLOGIP, BitmapValue)
@@ -2935,7 +2935,7 @@
ucb_bit_test(AllPurposeHV, DELETEUCB, BitmapValue)
} else {
if (!strcmp(InfoName, "TT_CHARSET")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
ttc_bit_test(AllPurposeHV, HANGUL, BitmapValue);
ttc_bit_test(AllPurposeHV, HANYU, BitmapValue);
ttc_bit_test(AllPurposeHV, HANZI, BitmapValue);
@@ -2944,7 +2944,7 @@
ttc_bit_test(AllPurposeHV, THAI, BitmapValue);
}}}}
if (AllPurposeHV) {
- XPUSHs(newRV((SV *)AllPurposeHV));
+ XPUSHs(newRV_noinc((SV *)AllPurposeHV));
} else {
XPUSHs(&PL_sv_undef);
}

--- vms-queue-0_57/queue.xs Wed May 30 17:18:05 2001
+++ vms-queue-0_58/queue.xs Mon Feb 27 12:25:30 2006
@@ -1031,7 +1031,7 @@
{
HV *AllPurposeHV;
if (!strcmp(InfoName, "FORM_FLAGS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_FORM_SHEET_FEED, "FORM_SHEET_FEED",
BitmapValue);
bit_test(AllPurposeHV, QUI$M_FORM_TRUNCATE, "FORM_TRUNCATE",
@@ -1039,7 +1039,7 @@
bit_test(AllPurposeHV, QUI$M_FORM_WRAP, "FORM_WRAP", BitmapValue);
} else {
if (!strcmp(InfoName, "FILE_FLAGS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_FILE_BURST, "FILE_BURST",
BitmapValue);
bit_test(AllPurposeHV, QUI$M_FILE_DELETE, "FILE_DELETE",
@@ -1058,14 +1058,14 @@
BitmapValue);
} else {
if (!strcmp(InfoName, "FILE_STATUS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_FILE_CHECKPOINTED, "FILE_CHECKPOINTED",
BitmapValue);
bit_test(AllPurposeHV, QUI$M_FILE_EXECUTING, "FILE_EXECUTING",
BitmapValue);
} else {
if (!strcmp(InfoName, "JOB_FLAGS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_JOB_CPU_LIMIT, "JOB_CPU_LIMIT", BitmapValue);
bit_test(AllPurposeHV, QUI$M_JOB_ERROR_RETENTION,
"JOB_ERROR_RETENTION", BitmapValue);
@@ -1096,7 +1096,7 @@
bit_test(AllPurposeHV, QUI$M_JOB_WSQUOTA, "JOB_WSQUOTA", BitmapValue);
} else {
if (!strcmp(InfoName, "JOB_STATUS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_JOB_ABORTING, "JOB_ABORTING", BitmapValue);
bit_test(AllPurposeHV, QUI$M_JOB_EXECUTING, "JOB_EXECUTING", BitmapValue);
bit_test(AllPurposeHV, QUI$M_JOB_HOLDING, "JOB_HOLDING", BitmapValue);
@@ -1112,7 +1112,7 @@
BitmapValue);
} else {
if (!strcmp(InfoName, "MANAGER_FLAGS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_MANAGER_FAILOVER, "MANAGER_FAILOVER",
BitmapValue);
bit_test(AllPurposeHV, QUI$M_MANAGER_RUNNING, "MANAGER_RUNNING",
@@ -1127,7 +1127,7 @@
BitmapValue);
} else {
if (!strcmp(InfoName, "PENDING_JOB_REASON")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_PEND_CHAR_MISMATCH, "PEND_CHAR_MISMATCH",
BitmapValue);
bit_test(AllPurposeHV, QUI$M_PEND_JOB_SIZE_MAX, "PEND_JOB_SIZE_MAX",
@@ -1144,7 +1144,7 @@
"PEND_STOCK_MISMATCH", BitmapValue);
} else {
if (!strcmp(InfoName, "QUEUE_FLAGS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_QUEUE_ACL_SPECIFIED,
"QUEUE_ACL_SPECIFIED", BitmapValue);
bit_test(AllPurposeHV, QUI$M_QUEUE_AUTOSTART, "QUEUE_AUTOSTART",
@@ -1199,7 +1199,7 @@
BitmapValue);
} else {
if (!strcmp(InfoName, "QUEUE_STATUS")) {
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
bit_test(AllPurposeHV, QUI$M_QUEUE_ALIGNING, "QUEUE_ALIGNING",
BitmapValue);
bit_test(AllPurposeHV, QUI$M_QUEUE_AUTOSTART_INACTIVE,
@@ -1377,7 +1377,7 @@
if ((status == SS$_NORMAL) && (GenericIOSB.sts == JBC$_NORMAL)) {
unsigned int *timeptr;
/* Looks like it */
- AllPurposeHV = newHV();
+ AllPurposeHV = (HV*)sv_2mortal((SV*)newHV());
for (i = 0; i < LocalIndex; i++) {
switch(OurDataList[i].ReturnType) {
case IS_STRING:

--
tom_p
pfau@nbpfaus.net -- http://nbpfaus.net/~pfau/


--
________________________________________
Craig A. Berry
mailto:craigberry@mac.com

"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Wed Dec 03, 2008 1:39 am | All times are GMT
navigation Forum index » Not Unix » VMS » vmsperl
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts postfix out of memory error - please help metind Postfix 0 Mon Sep 11, 2006 1:54 am
No new posts Non IBM memory in p630 Ron AIX 0 Fri Jul 21, 2006 2:05 pm
No new posts database Share Memory Limit (2 GB ) in a Instance is tota... sadanjan@gmail.com IBM DB2 0 Fri Jul 21, 2006 12:57 pm
No new posts Where is this code not freeing memory ? jithoosin C++ 2 Fri Jul 21, 2006 9:39 am
No new posts Where is this code not freeing memory ? jithoosin C++ 1 Fri Jul 21, 2006 9:27 am

Loans | Repair Bad Credit | Mobile Phones | Internet Advertising | Secure Hosting
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2802s ][ Queries: 16 (0.1905s) ][ GZIP on - Debug on ]