Re: heap memory



On Feb 25, 12:20 am, "Andrea" <andre...@xxxxxxxx> wrote:
"Daniel Pitts" <googlegrou...@xxxxxxxxxxxxx> ha scritto nel messaggionews:1172341456.008187.49910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



On Feb 24, 4:22 am, "Andrea" <andre...@xxxxxxxx> wrote:
Hi all,
I've a jsp-form which inquiry a database with a sql-query, and obtain a
recordset placed in a type-Vector variable; all working fine when I
expose
this result in a html-page.
Now I need to expose same result in a Excel worksheet, so now my jsp
contain
this code string:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition",
"attachment;filename=report_wiz.xls");
All working fine until (I suppose) Vector extracted is "light", but if
it's
"heavy" in its dimension then I have an error page instead my xls sheet
with
data inside.
I can expand my java-container with this parameter:
-Xms512m -Xmx512m
but could be not sufficient!
So, there is a way to intercept Vector-dimension? If yes, I can check
this
before pass it to Excel-page, and if it's too big I can throw an alert
like
"too much fields or too much rows extracted" to my users, instead a bad
error-page.
Thanks in advance
JFM

First, you don't tell us what database interface you are using, JDBC?
iBATIS? Hibernate?

Some data access frameworks allow you to use lazy loading, and/or row
handling. This allows you to only load into memory what you need.

Alternatively, you can add a new SQL query that is like your original
query, but returns the number of rows.

Original: SELECT a, b, c FROM table_a WHERE a=b+1 <etc...>
Counting: SELECT COUNT(*) FROM table_a WHERE a=b+1 <etc...>

Hi Daniel,
sorry, I have a JDBC interface to an Oracle database.
And about second suggestion, number and type of field selected can be
changed at each inqury, so a "select count(*)" not solve my trouble. Two
example: I can exctract 50000 rows with only a numeric field (and this works
fine), or 20000 rows composed by twenty fields (some numeric, some
varchar)... and is exactly this last event which cause my trouble.
Two seconds ago, I find this method:
vector.capacity()
now I go to search documentation about in order to see if it can help me; do
you know if this method could be ad-hoc for my problem?
Thanks again
JFM

If you have control of the code that adds the data into the Vector,
change it to instead process it as a stream of rows! Many people find
it easier conceptually to deal with a Vector, however, often times you
can minimize memory requirements by changing your algorithms to
stream.

Well, hope this helps.
Daniel.

.



Relevant Pages

  • Re: heap memory
    ... I have a JDBC interface to an Oracle database. ... so a "select count" not solve my trouble. ... now I go to search documentation about in order to see if it can help ... change it to instead process it as a stream of rows! ...
    (comp.lang.java.programmer)
  • Re: heap memory
    ... I have a JDBC interface to an Oracle database. ... so a "select count" not solve my trouble. ... now I go to search documentation about in order to see if it can help ... change it to instead process it as a stream of rows! ...
    (comp.lang.java.programmer)
  • Re: heap memory
    ... First, you don't tell us what database interface you are using, JDBC? ... you can add a new SQL query that is like your original ... so a "select count" not solve my trouble. ... I can exctract 50000 rows with only a numeric field (and this works ...
    (comp.lang.java.programmer)
  • Re: Can images be saved to Session State and retrieved?
    ... session state object and convert to bitmap. ... > here is the code to retrieve the image from the database. ... > //Creating memory stream with the raw image data ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: The argument for fs assistance in handling archives
    ... Modern operating systems such as VMS with basic database ... as a byte stream and that the interpretation of the contents of a file ... that there are features that can only be provided by ... database has been tried before, ISAM is a very old concept. ...
    (Linux-Kernel)