Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Java] Memory leak due to table writers never being destroyed after done writing #17720

Open
ttnghia opened this issue Jan 11, 2025 · 0 comments
Labels
bug Something isn't working Java Affects Java cuDF API. Spark Functionality that helps Spark RAPIDS

Comments

@ttnghia
Copy link
Contributor

ttnghia commented Jan 11, 2025

For all kinds of table writers (Java code: Table.java, JNI code: TableJni.cpp), the native C++ instances are never destroyed after calling close() in the corresponding Java classes. For example:

@Override
    public void close() throws CudfException {
      if (writerHandle != 0) {
        writeParquetEnd(writerHandle);
      }
      writerHandle = 0;

And here is the C++ function writeParquetEnd:

  try {
    cudf::jni::auto_set_device(env);
    state->writer->close();
  }

Note that state is an unmanaged pointer that corresponds to writerHandle in Java and stores writer as a unique_ptr. So the writer instance is destroyed automatically when state is destroyed, however, state is never destroyed.

When writeParquetEnd is called, the C++ code only calls the member close() function of the writer, never calls delete on the state instance. After this, the Java code simply leaves that native instance dangled.

@ttnghia ttnghia added bug Something isn't working Java Affects Java cuDF API. Spark Functionality that helps Spark RAPIDS labels Jan 11, 2025
@ttnghia ttnghia changed the title [BUG] [Java] Memory leak due to table writers are never destroyed [BUG] [Java] Memory leak due to table writers never being destroyed after done writing Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Java Affects Java cuDF API. Spark Functionality that helps Spark RAPIDS
Projects
None yet
Development

No branches or pull requests

1 participant