Did you increase the heap size before starting anyway ?
Something like -Xmx1024M -Xms1024M

The default is 160K or something like that, which is not much ...

----- Original Message ----- From: "Jason Berk" <jb...@purdueefcu.com>
To: <user@xmlbeans.apache.org>
Sent: Tuesday, September 15, 2009 3:01 PM
Subject: heap error


Do I have a memory leak here:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
....
at
com.purdueefcu.statements.services.regmember.RegularMemberStatementServi
ce.bind(RegularMemberStatementService.java:67)
....

What isn't being garbage collected and leaking memory?  Is the parsed
XML document being cached?

I'm selecting xml docs from the DB and binding them.  I'm not doing
anything with the bound object...just testing the binding.



public abstract class BaseService {

protected Connection connection;

public void setDataSource(DataSource ds) throws Exception {
this.connection = ds.getConnection();
}

public abstract void init() throws Exception;

public void close() throws Exception {
this.connection.close();
}
}

public class RegularMemberStatementService extends BaseService
implements StatementService {

private static final Logger logger =
Logger.getLogger(RegularMemberStatementService.class.getName());

private static final String PSTMTOUT_QUERY = "SELECT pstmtout
FROM pstmtout WHERE account = ?";

private static final String HELOC_APR_QUERY = "SELECT next_apr
FROM heloc_apr WHERE account = ? and suffix = ?";

private static final String SCORECARD_QUERY = "SELECT pan,
from_date, thru_date, beginning_balance,"
+ " base_pts, bonus_pts, adjusted_pts,
redeemed_pts, expired_pts, ending_balance"
+ " FROM scorecard WHERE account = ?";

private PreparedStatement pstmtoutPS;
private PreparedStatement helocAprPS;
private PreparedStatement scorecardPS;
private XMLReader xmlReader;

public void init() throws Exception {
pstmtoutPS =
connection.prepareStatement(PSTMTOUT_QUERY);
helocAprPS =
connection.prepareStatement(HELOC_APR_QUERY);
scorecardPS =
connection.prepareStatement(SCORECARD_QUERY);
xmlReader =
SAXParserFactory.newInstance().newSAXParser().getXMLReader();
}

@Override
public Object getStatementForAccount(long account) throws
Exception {
pstmtoutPS.setLong(1, account);
ResultSet rs = pstmtoutPS.executeQuery();
rs.next();
MemberStatement memberStatement =
bind(rs.getString("pstmtout"));
setNextAprForHelocs(memberStatement);
setScorecards(memberStatement);
rs.close();
return memberStatement;
}

private MemberStatement bind(String xml) throws Exception {
ArrayList<XmlValidationError> validationErrors = new
ArrayList<XmlValidationError>();
XmlOptions validationOptions = new XmlOptions();
validationOptions.setErrorListener(validationErrors);
validationOptions.setLoadLineNumbers();
validationOptions.setLoadTrimTextBuffer();
validationOptions.setUnsynchronized();
validationOptions.setLoadUseXMLReader(xmlReader);
MemberStatementDocument doc =
MemberStatementDocument.Factory.parse(xml, validationOptions);
if (!doc.validate(validationOptions)) {
logger.error("Validation errors discovered
during binding:");
Iterator<XmlValidationError> iter =
validationErrors.iterator();
while (iter.hasNext()) {
logger.error(">> " + iter.next());
}
throw new XmlException("Validation errors
discovered during binding:");
}
MemberStatement memberStatement =
doc.getMemberStatement();
if (memberStatement.getUnknownShareList().size() > 0 ||
memberStatement.getUnknownLoanList().size() > 0) {
throw new XmlException("account contains unknown
shares or loans");
}
return memberStatement;
}

private void setNextAprForHelocs(MemberStatement
memberStatement) throws Exception {
for (HelocLoanType heloc :
memberStatement.getHelocLoanList()) {
int account =
memberStatement.getAccountInfo().getAccountNumber();
int suffix =
Integer.parseInt(heloc.getSuffix());
if (logger.isDebugEnabled()) {
logger.debug("getting next apr for
account " + account + " suffix " + suffix);
}
helocAprPS.setInt(1, account);
helocAprPS.setInt(2, suffix);
ResultSet rs = helocAprPS.executeQuery();
rs.next();
heloc.setNextApr(rs.getInt("next_apr"));
}
}

private void setScorecards(MemberStatement memberStatement)
throws Exception {
int account =
memberStatement.getAccountInfo().getAccountNumber();
if (logger.isDebugEnabled()) {
logger.debug("adding scorecard(s) for account "
+ account);
}
scorecardPS.setInt(1, account);
ResultSet rs = scorecardPS.executeQuery();
while (rs.next()) {
ScorecardType scorecard =
memberStatement.addNewScorecard();
scorecard.setPan(rs.getLong("pan"));

Calendar fromCal = Calendar.getInstance();
fromCal.clear();
fromCal.setTime(rs.getDate("from_date"));
scorecard.setFromDate(fromCal);

Calendar thruCal = Calendar.getInstance();
thruCal.clear();
thruCal.setTime(rs.getDate("thru_date"));
scorecard.setFromDate(thruCal);


scorecard.setBegBalance(rs.getLong("beginning_balance"));
scorecard.setBasePts(rs.getLong("base_pts"));
scorecard.setBonusPts(rs.getLong("bonus_pts"));

scorecard.setAdjustedPts(rs.getLong("adjusted_pts"));

scorecard.setRedeemedPts(rs.getLong("redeemed_pts"));

scorecard.setExpiredPts(rs.getLong("expired_pts"));

scorecard.setEndingBalance(rs.getLong("ending_balance"));
}
}
}
Now serving Boiler Spirit with every purchase. Switch to the new Purdue debit card today. Show your pride and earn Scorecard Rewards on the side. Just sign for your purchases and score valuable rewards points you can use for travel, electronics or even cash.



***This is a transmission from Purdue Employees Federal Credit
Union (PEFCU) and is intended solely for its authorized
recipient(s), and may contain information that is confidential
and or legally privileged.  If you are not an addressee, or the
employee or agent responsible for delivering it to an addressee,
you are hereby notified that any use, dissemination,
distribution, publication or copying of the information
contained
in this email is strictly prohibited. If you have received this
transmission in error, please notify us by telephoning (765)
497-3328 or returning the email. You are then instructed to
delete the information from your computer.  Thank you for your
cooperation.***


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: user-h...@xmlbeans.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: user-h...@xmlbeans.apache.org

Reply via email to