You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
I'm encountering a memory leak issue in my application while utilizing the dependency injection library in conjunction with AWS S3 services. My current implementation involves creating a singleton container that maintains a single instance of the dependency injection container (DIContainer) throughout the application's lifecycle. However, this approach has led to a continuous increase in memory consumption as file uploads to S3 are performed.
Current Scenario:
The implementation of my singleton container is as follows:
The issue I've been facing is that the container is instantiated only at the entrypoint of the application, causing the service responsible for communicating with S3 to persist in memory even after uploads have been completed. This has resulted in a continuous increase in memory consumption, subsequently affecting my application's performance.
For instance, during my tests, I noticed that after around 100 requests to upload files of approximately 10MB each (totaling around 1GB), the AWS S3 library began to experience failures.
Current Solution:
To work around this issue, I had to resort to a suboptimal solution involving re-creating the S3 library instance every time an upload is performed. While this solution resolved the memory leak and performance problems, I recognize that it's not the cleanest approach.
Seeking Help: I'm in search of a more elegant solution to this problem. I would like to know if it's possible to elegantly recreate the service instance every time the get() method of the DIContainer is invoked. My attempt to recreate the service instance was as follows:
container.add({FileDriver: object(S3FileDriver)// attempted using factory, func, etc...});container.get("FileDriver");// the goal is to recreate the instance here
Questions:
Is there a more effective way to manage S3 service instances within the context of dependency injection to prevent memory leaks and excessive consumption?
Can I recreate the instance of a specific service every time the get() method of the DIContainer is called? If so, how can I implement this properly and cleanly?
I appreciate any guidance and suggestions in advance to efficiently and elegantly resolve this issue.
The text was updated successfully, but these errors were encountered:
Summary:
I'm encountering a memory leak issue in my application while utilizing the dependency injection library in conjunction with AWS S3 services. My current implementation involves creating a singleton container that maintains a single instance of the dependency injection container (DIContainer) throughout the application's lifecycle. However, this approach has led to a continuous increase in memory consumption as file uploads to S3 are performed.
Current Scenario:
The implementation of my singleton container is as follows:
The issue I've been facing is that the container is instantiated only at the entrypoint of the application, causing the service responsible for communicating with S3 to persist in memory even after uploads have been completed. This has resulted in a continuous increase in memory consumption, subsequently affecting my application's performance.
For instance, during my tests, I noticed that after around 100 requests to upload files of approximately 10MB each (totaling around 1GB), the AWS S3 library began to experience failures.
Current Solution:
To work around this issue, I had to resort to a suboptimal solution involving re-creating the S3 library instance every time an upload is performed. While this solution resolved the memory leak and performance problems, I recognize that it's not the cleanest approach.
Seeking Help: I'm in search of a more elegant solution to this problem. I would like to know if it's possible to elegantly recreate the service instance every time the
get()
method of the DIContainer is invoked. My attempt to recreate the service instance was as follows:Questions:
get()
method of the DIContainer is called? If so, how can I implement this properly and cleanly?I appreciate any guidance and suggestions in advance to efficiently and elegantly resolve this issue.
The text was updated successfully, but these errors were encountered: