[Helma-user] Java heap space in dbh.query()
Joshua Paine
joshua at papercrown.org
Sun Jul 22 05:47:11 CEST 2007
Julian Tree wrote:
> "Java heap space" error.
Look in Helma's start.bat or start.sh file. You'll find a line which may
be commented out that says something like:
set JAVA_OPTIONS=-server -Xmx128m
Uncomment (if necessary) and try doubling the -Xmx value, e.g., to
-Xmx256m. (And then try doubling again if necessary and if you have the
RAM.) But if that does the trick it means you were running out of
memory, and if that happens now in development it's probably likely to
happen again with heavier traffic in production, even with an increased
memory limit.
The two obvious approaches are:
1) Don't get 3000 records. Humans can't usually make use of so many
anyway--is there a way you could use limit clauses to offer paged
results or something instead?
2) In most environments, the database driver can return a result set
which lets you work with one result row at a time without loading them
all into memory. Helma's Database object is extremely rudimentary,
however, and doesn't offer this feature (nor parameterized/prepared
statements--it's really not meant for serious DB work since they're
expecting you to use the built-in ORM for most things). You can get that
feature by dropping down to Java or by directly managing Java's database
access stuff through Rhino's Java/JavaScript interfaces (don't ask me
how, I haven't the slightest) or you can simulate it by running the
query with limit clauses in a loop to retrieve, e.g., 100 rows at a
time, do your work with them, delete the array, and then get another 100.
> cachesize = 300000
This affects only the in-memory cache of HopObjects. If anything,
increasing it will lead to *more* memory problems.
-Joshua
More information about the Helma-user
mailing list