Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49740c5

Browse files
committed
Attached are patches for two fixes to reduce memory usage by the JDBC
drivers.The first fix fixes the PreparedStatement object to not allocateunnecessary objects when converting native types to Stings. The oldcode used the following format: (new Integer(x)).toString()whereas this can more efficiently be occompilshed by: Integer.toString(x);avoiding the unnecessary object creation.The second fix is to release some resources on the close() of aResultSet. Currently the close() method on ResultSet is a noop. Thepurpose of the close() method is to release resources when the ResultSetis no longer needed. The fix is to free the tuples cached by theResultSet when it is closed (by clearing out the Vector object thatstores the tuples). This is important for my application, as I have acache of Statement objects that I reuse. Since the Statement objectmaintains a reference to the ResultSet and the ResultSet kept referencesto the old tuples, my cache was holding on to a lot of memory.Barry Lind
1 parenta057cbe commit49740c5

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

‎src/interfaces/jdbc/org/postgresql/jdbc1/PreparedStatement.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void setBoolean(int parameterIndex, boolean x) throws SQLException
164164
*/
165165
publicvoidsetByte(intparameterIndex,bytex)throwsSQLException
166166
{
167-
set(parameterIndex,(newInteger(x)).toString());
167+
set(parameterIndex,Integer.toString(x));
168168
}
169169

170170
/**
@@ -177,7 +177,7 @@ public void setByte(int parameterIndex, byte x) throws SQLException
177177
*/
178178
publicvoidsetShort(intparameterIndex,shortx)throwsSQLException
179179
{
180-
set(parameterIndex,(newInteger(x)).toString());
180+
set(parameterIndex,Integer.toString(x));
181181
}
182182

183183
/**
@@ -190,7 +190,7 @@ public void setShort(int parameterIndex, short x) throws SQLException
190190
*/
191191
publicvoidsetInt(intparameterIndex,intx)throwsSQLException
192192
{
193-
set(parameterIndex,(newInteger(x)).toString());
193+
set(parameterIndex,Integer.toString(x));
194194
}
195195

196196
/**
@@ -203,7 +203,7 @@ public void setInt(int parameterIndex, int x) throws SQLException
203203
*/
204204
publicvoidsetLong(intparameterIndex,longx)throwsSQLException
205205
{
206-
set(parameterIndex,(newLong(x)).toString());
206+
set(parameterIndex,Long.toString(x));
207207
}
208208

209209
/**
@@ -216,7 +216,7 @@ public void setLong(int parameterIndex, long x) throws SQLException
216216
*/
217217
publicvoidsetFloat(intparameterIndex,floatx)throwsSQLException
218218
{
219-
set(parameterIndex,(newFloat(x)).toString());
219+
set(parameterIndex,Float.toString(x));
220220
}
221221

222222
/**
@@ -229,7 +229,7 @@ public void setFloat(int parameterIndex, float x) throws SQLException
229229
*/
230230
publicvoidsetDouble(intparameterIndex,doublex)throwsSQLException
231231
{
232-
set(parameterIndex,(newDouble(x)).toString());
232+
set(parameterIndex,Double.toString(x));
233233
}
234234

235235
/**

‎src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public boolean next() throws SQLException
127127
*/
128128
publicvoidclose()throwsSQLException
129129
{
130-
// No-op
130+
//release resources held (memory for tuples)
131+
rows.setSize(0);
131132
}
132133

133134
/**

‎src/interfaces/jdbc/org/postgresql/jdbc2/PreparedStatement.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void setBoolean(int parameterIndex, boolean x) throws SQLException
164164
*/
165165
publicvoidsetByte(intparameterIndex,bytex)throwsSQLException
166166
{
167-
set(parameterIndex,(newInteger(x)).toString());
167+
set(parameterIndex,Integer.toString(x));
168168
}
169169

170170
/**
@@ -177,7 +177,7 @@ public void setByte(int parameterIndex, byte x) throws SQLException
177177
*/
178178
publicvoidsetShort(intparameterIndex,shortx)throwsSQLException
179179
{
180-
set(parameterIndex,(newInteger(x)).toString());
180+
set(parameterIndex,Integer.toString(x));
181181
}
182182

183183
/**
@@ -190,7 +190,7 @@ public void setShort(int parameterIndex, short x) throws SQLException
190190
*/
191191
publicvoidsetInt(intparameterIndex,intx)throwsSQLException
192192
{
193-
set(parameterIndex,(newInteger(x)).toString());
193+
set(parameterIndex,Integer.toString(x));
194194
}
195195

196196
/**
@@ -203,7 +203,7 @@ public void setInt(int parameterIndex, int x) throws SQLException
203203
*/
204204
publicvoidsetLong(intparameterIndex,longx)throwsSQLException
205205
{
206-
set(parameterIndex,(newLong(x)).toString());
206+
set(parameterIndex,Long.toString(x));
207207
}
208208

209209
/**
@@ -216,7 +216,7 @@ public void setLong(int parameterIndex, long x) throws SQLException
216216
*/
217217
publicvoidsetFloat(intparameterIndex,floatx)throwsSQLException
218218
{
219-
set(parameterIndex,(newFloat(x)).toString());
219+
set(parameterIndex,Float.toString(x));
220220
}
221221

222222
/**
@@ -229,7 +229,7 @@ public void setFloat(int parameterIndex, float x) throws SQLException
229229
*/
230230
publicvoidsetDouble(intparameterIndex,doublex)throwsSQLException
231231
{
232-
set(parameterIndex,(newDouble(x)).toString());
232+
set(parameterIndex,Double.toString(x));
233233
}
234234

235235
/**

‎src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ public boolean next() throws SQLException
128128
*/
129129
publicvoidclose()throwsSQLException
130130
{
131-
// No-op
131+
//release resources held (memory for tuples)
132+
rows.setSize(0);
132133
}
133134

134135
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp