Kbase P84199: JDBC Prepared Statements are consuming excessive RAM
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  11/10/2004 |
|
Status: Unverified
FACT(s) (Environment):
Progress 9.1x
SYMPTOM(s):
Prepared Statements from JDBC are consuming excessive RAM.
Each Prepared Statement is consuming about 12 MB of RAM.
Creating Prepared Statements in a loop without invoking the close() method.
Each table referenced in the Prepared Statement contains several VARCHAR columns which are 30 KB in size.
CAUSE:
This is expected behavior.
This behavior is part of the current JDBC driver implementation, the following example illustrates why:
Let's assume by average each table has four columns of VARCHAR with size of 30 KB each. With the current JDBC driver implementation, each row of one table will allocate 30 KB * 4 = 120 KB of memory. Additionally when preparing the statement, the JDBC driver preserves 100 rows for each fetch. So a Prepared Statement of a table will need 120 KB * 100 = 12 MB. Assuming that 100 statements are being prepared in a loop without releasing the memory, then this will result in a total of 1.2 GB of memory consumption.
FIX:
Decrease the size of the VARCHAR columns.
- OR -
1) Create a limited amount of Prepared Statements.
2) Before creating additional Prepared Statements, release the allocated memory of any unused Prepared Statement by invoking the close() method.