JDK-8211393 : Memory leak issue on awt_InputMethod.c
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt:i18n
  • Affected Version: 11,12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,aix
  • CPU: generic
  • Submitted: 2018-10-02
  • Updated: 2019-10-20
  • Resolved: 2018-10-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12
11.0.4Fixed 12 b17Fixed
Description
Memory leak issue on awt_InputMethod.c.

See src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c.
On line 1117, memory area was allocated by malloc(), but free() is missing
===========================================
  1099          if (text->feedback != NULL) {
  1100              int cnt;
  1101              jint *tmpstyle;
  1102
  1103              style = (*env)->NewIntArray(env, text->length);
  1104              if (JNU_IsNull(env, style)) {
  1105                  (*env)->ExceptionClear(env);
  1106                  THROW_OUT_OF_MEMORY_ERROR();
  1107                  goto finally;
  1108              }
  1109
  1110              if (sizeof(XIMFeedback) == sizeof(jint)) {
  1111                  /*
  1112                   * Optimization to avoid copying the array
  1113                   */
  1114                  (*env)->SetIntArrayRegion(env, style, 0,
  1115                                            text->length, (jint *)text->feedback);
  1116              } else {
  1117                  tmpstyle  = (jint *)malloc(sizeof(jint)*(text->length));
  1118                  if (tmpstyle == (jint *) NULL) {
  1119                      THROW_OUT_OF_MEMORY_ERROR();
  1120                      goto finally;
  1121                  }
  1122                  for (cnt = 0; cnt < (int)text->length; cnt++)
  1123                          tmpstyle[cnt] = text->feedback[cnt];
  1124                  (*env)->SetIntArrayRegion(env, style, 0,
  1125                                            text->length, (jint *)tmpstyle);
  1126              }
  1127          }
===========================================

RFR:
http://mail.openjdk.java.net/pipermail/awt-dev/2018-October/014390.html

Reviewers
http://mail.openjdk.java.net/pipermail/awt-dev/2018-October/014391.html
http://mail.openjdk.java.net/pipermail/awt-dev/2018-October/014415.html
Comments
Fix Request It's memory leak issue on GUI applications, and I'd like to request the fix in 11u. The patch could apply cleanly.
28-02-2019