Subject: | Memory leak.... |
Date: | Mon, 24 Nov 2008 16:35:34 -0600 |
To: | "bug-WWW-Salesforce [...] rt.cpan.org" <bug-WWW-Salesforce [...] rt.cpan.org> |
From: | James Christensen <James.Christensen [...] nimsoft.com> |
I am attempting to create an integration between SalesForce and an enterprise systems monitoring and management solution. The integration piece will create a new Case when an alert/alarm is generated. This is based on supplied criteria within the monitoring solution. The integration will track a relationship of an alarm id to the created case number. Periodically (user specified interval) a query will be made to get the status of the case (Is it closed?). If closed, the alert.alarm will also be closed and the alarm id -> case number relationship deleted. The integration runs as a daemon process. Everytime a call is made to the WWW::Salesforce::Simple module, the amount of memory consumed by the process increases eventually taking all the memory. The memory consumption also increases when ever a new case is created also.
Perl Module - WWW-Salesforce-0.090 / WWW-Salesforce-Simple 0.092
Perl version 5.8.8
OS - MS Windows XP SP2
The sub routine that performs the query ...............
Note: the initial creation/authentication of the SalesForce object is now at the global scope so it is only performed once.
###########################################################
sub isclosed {
my $incident = shift;
nimLog(0,"[isclosed] Checking to see if incident $incident is closed");
# my $pwd = $sfdcpwd . $sfdctoken;
# Authenticate with the Salesforce API
# my $sforce_query = WWW::Salesforce::Simple->new(
# 'username' => $sfdcuser,
# 'password' => $pwd
# );
my $query = "select IsClosed from Case where CaseNumber = '$incident'";
my $qresult = $sforce_query->do_query($query,100);
if ($qresult->[0]) {
if ($qresult->[0]->{'IsClosed'} eq "true") {
nimLog(0,"[isclosed] Case Number: $incident has been closed");
undef ($qresult);
return 1;
}
else {
nimLog(0,"[isclosed] Case Number: $incident is still open");
}
}
else {
nimLog(0,"[isclosed] Case Number: $incident not found");
}
undef ($qresult);
return 0;
}
############################################################################
The sub routine that is calling the isclosed routine listed above.
###########################################################################
sub timeout {
my $now = time();
return if ($now < $next_run);
$next_run = $now + $interval;
nimLog(0,"[timeout] Doing work at $now");
foreach my $incident (keys %Xincidents) {
my $nimid = $Xincidents{$incident};
if($nimid eq "") {
nimLog(0,"[timeout] No incident or nimid to process");
}
else {
if (isclosed($incident) == 1) {
nimLog(0,"[timeout] Incident $incident is closed. Alarm $nimid will be closed");
closealarm($nimid);
eraseconfigentry($incident, $nimid);
}
}
}
}
###########################################################
Jim Christensen
(650) 931-1146 o
(650) 766-5514 c
http://www.nimsoft.com<http://www.nimsoft.com/>
[cid:image001.jpg@01C94E41.A603AFB0]
Message body is not shown because it is too large.