The parse function was leaking memory. On analysis of the code it looked like the fileOpen function was keeping the memory active, after the file was being used.
Changed the io.Reader to io.ReadCloser in Open signature
Changed the io.Reader to io.ReadCloser in osOpen signature
Added defer to close the file after function exit in Parse
A snapshot of the memory in the NGINX Agent before these changes:
and after:
Checklist
Before creating a PR, run through this checklist and mark each as complete.
Proposed changes
The parse function was leaking memory. On analysis of the code it looked like the fileOpen function was keeping the memory active, after the file was being used.
A snapshot of the memory in the NGINX Agent before these changes:![image](https://github.com/nginxinc/nginx-go-crossplane/assets/496642/3da14ca1-2947-4011-86c9-6a6c5d15abc6)
and after:![image](https://github.com/nginxinc/nginx-go-crossplane/assets/496642/9d614364-3000-467e-9412-b9f31abc4913)
Checklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTING
documentREADME.md
)