-
Bug
-
Resolution: Fixed
-
P4
-
1.4.2, 6
-
b85
-
x86
-
windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2144825 | 5.0u12 | Poonam Bajaj Parhar | P2 | Resolved | Fixed | b01 |
JDK-2144534 | 1.4.2_15 | Poonam Bajaj Parhar | P2 | Resolved | Fixed | b01 |
FULL PRODUCT VERSION :
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode)
but also higher and lower.
ADDITIONAL OS VERSION INFORMATION :
on all OS platforms
EXTRA RELEVANT SYSTEM CONFIGURATION :
standalone java example
A DESCRIPTION OF THE PROBLEM :
example, which performs
java.net.URLEncoder.encode(String ..) in a main method with the string parameter a string which is 30 kb in size.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the code, which we have rovided in the "Source code for an executable test case:" point of this questionary.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
We expect that the trashed memory does not exceed the size of the encoded string more than 3 times.
The URL encoding is widely used in the webdynpro and portal layers of SAP products, therefore we expect fix of the problem with very high priority.
ACTUAL -
The actual memory consumption for different tested string lengths is
The heading for the columns below are -
1) Length of string (number of characters)
2) Length of string which is encoded/decoded in kb
3) Processing memory (kb) ENCODING
4) Processing memory (kb) DECODING
10 0.009 18 1.16
50 0.048 52 2.96
100 0.09 103 4.44
200 0.19 189 7.94
300 0.29 275 12
400 0.39 360 16
500 0.48 455 20
where decoding we would say is fine, but encoding is real problem
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class URLTest {
public static void main(String[] args) {
boolean encode = true;
if (args[0].equals("-encode")) {
encode = true;
} else if (args[0].equals("-decode")) {
encode = false;
}
int iterations = Integer.parseInt(args[1]);
String teststring = args[2];
System.out.println(teststring);
System.out.println("Test string length is " + teststring.length() + " bytes.");
if (encode) {
System.out.println("Will be encoded " + iterations + " times.");
} else {
System.out.println("Will be decoded " + iterations + " times.");
}
try {
Thread.sleep(30000);
} catch (InterruptedException iio) {
}
Runtime.getRuntime().gc();
for (int i = 0; i < iterations; i++) {
if (encode) {
URLEncoder.encode(teststring);
} else {
URLDecoder.decode(teststring);
}
try {
Thread.sleep(30000);
} catch (InterruptedException iio) {
}
}
Runtime.getRuntime().gc();
}
}
During the Thread.sleep we attach and detach profiler and make the memory snapshot, or when we run w/o profiler we check the gclog file - both approached confirm the high memory allocations.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
there is not workaround.
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode)
but also higher and lower.
ADDITIONAL OS VERSION INFORMATION :
on all OS platforms
EXTRA RELEVANT SYSTEM CONFIGURATION :
standalone java example
A DESCRIPTION OF THE PROBLEM :
example, which performs
java.net.URLEncoder.encode(String ..) in a main method with the string parameter a string which is 30 kb in size.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the code, which we have rovided in the "Source code for an executable test case:" point of this questionary.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
We expect that the trashed memory does not exceed the size of the encoded string more than 3 times.
The URL encoding is widely used in the webdynpro and portal layers of SAP products, therefore we expect fix of the problem with very high priority.
ACTUAL -
The actual memory consumption for different tested string lengths is
The heading for the columns below are -
1) Length of string (number of characters)
2) Length of string which is encoded/decoded in kb
3) Processing memory (kb) ENCODING
4) Processing memory (kb) DECODING
10 0.009 18 1.16
50 0.048 52 2.96
100 0.09 103 4.44
200 0.19 189 7.94
300 0.29 275 12
400 0.39 360 16
500 0.48 455 20
where decoding we would say is fine, but encoding is real problem
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class URLTest {
public static void main(String[] args) {
boolean encode = true;
if (args[0].equals("-encode")) {
encode = true;
} else if (args[0].equals("-decode")) {
encode = false;
}
int iterations = Integer.parseInt(args[1]);
String teststring = args[2];
System.out.println(teststring);
System.out.println("Test string length is " + teststring.length() + " bytes.");
if (encode) {
System.out.println("Will be encoded " + iterations + " times.");
} else {
System.out.println("Will be decoded " + iterations + " times.");
}
try {
Thread.sleep(30000);
} catch (InterruptedException iio) {
}
Runtime.getRuntime().gc();
for (int i = 0; i < iterations; i++) {
if (encode) {
URLEncoder.encode(teststring);
} else {
URLDecoder.decode(teststring);
}
try {
Thread.sleep(30000);
} catch (InterruptedException iio) {
}
}
Runtime.getRuntime().gc();
}
}
During the Thread.sleep we attach and detach profiler and make the memory snapshot, or when we run w/o profiler we check the gclog file - both approached confirm the high memory allocations.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
there is not workaround.
- backported by
-
JDK-2144534 30 MB memory trashed to get 30 kb string url encoded
- Resolved
-
JDK-2144825 30 MB memory trashed to get 30 kb string url encoded
- Resolved
- duplicates
-
JDK-6368633 java.net.URLEncoder.encode performance enhancements
- Closed
- relates to
-
JDK-4407610 java.net.URLDecode.decode(st,"UTF-16") works incorrectly on '+' sign
- Resolved
-
JDK-6437829 java.net.URLEncoder.encode should be optimized for multi-threading
- Closed
-
JDK-6351680 java.net.URLEncoder consumes a lot of CPU and memory.
- Closed
(1 relates to)