xcx1r3 opened a new issue, #13243:
URL: https://github.com/apache/iceberg/issues/13243

   ### Proposed Change
   
   Resource leaks are a critical concern in software development and system 
design. A resource leak occurs when a program allocates a system or limited 
resource (such as memory, file handles, network connections, or database 
connections) but fails to release it after its use is complete. Over time, 
these unreleased resources accumulate, leading to serious performance 
degradation, instability, and even system failure.
   
   I found some code that may be leaking resources.
   # leak1 
   `org.apache.iceberg.avro.AvroEncoderUtil#encode`  DataOutputStream dataOut 
   
   
![Image](https://github.com/user-attachments/assets/6efb8acb-11f8-4f36-a0c7-9048ebcb40fa)
   While the underlying stream out (the ByteArrayOutputStream) will be closed 
automatically by the try-with-resources statement, this does not trigger the 
close() method of the DataOutputStream (dataOut) that wraps it
   
   # leak2
   `org.apache.iceberg.flink.sink.shuffle.DataStatisticsSerializer#deserialize` 
  Memory sketchMemory
   
   
![Image](https://github.com/user-attachments/assets/1c4fbd47-a917-4b45-8a6f-1a5018a09ac3)
   
   no sketchMemory.close() call
   
   # leak3
   `org.apache.iceberg.hadoop.HadoopFileIO#deleteFile`  FileSystem fs
   
   
![Image](https://github.com/user-attachments/assets/ad94b3fc-0d0f-4af5-87f8-c229033f16d4)
   no close call
   
   # leak 4
   `org.apache.iceberg.hadoop.HadoopFileIO#deletePrefix`  FileSystem fs
   
   
![Image](https://github.com/user-attachments/assets/32d9f2b8-dd69-4170-84af-f688628b4916)
   no close call
   
   # leak 5
   `org.apache.iceberg.hadoop.Util#blockLocations`  FileSystem fs
   
   
![Image](https://github.com/user-attachments/assets/7cbf6322-d400-4f1a-98d4-7a451fd8ef07)
   no close call
   
   # Fix
   Use a `try-with-resources` statement to ensure the resource object is 
automatically closed
   
   ### Proposal document
   
   _No response_
   
   ### Specifications
   
   - [ ] Table
   - [ ] View
   - [ ] REST
   - [ ] Puffin
   - [ ] Encryption
   - [x] Other


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to