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

Closing the file stream after saving the evaluation data #4841

Closed
wants to merge 1 commit into from

Conversation

FauziAkram
Copy link
Contributor

Closing the file stream after saving the evaluation data to avoid resource leaks.

When we open a file stream (e.g., using std::ofstream), the operating system allocates resources to handle the file. These resources may include file handles, buffers, and other data structures.
If we don't explicitly close the file stream after you're done with it, the file remains open, and its associated resources are not released.

Closing a file stream is a best practice for resource management. It ensures that data is written to the file, and prevents resource exhaustion, data loss, and file-locking issues.

No functional change, bench: 1241996

bench: 1241996
@Disservin
Copy link
Member

That's a bit redudant imo, ofstream should be an RAII object which closes automatically at the end of the scope. Which in this case is 3 lines below.

@FauziAkram FauziAkram closed this Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants