vlio20 / utils-decorators

Decorators for web and node applications
https://vlio20.github.io/utils-decorators/
MIT License
216 stars 13 forks source link

Timer, to clear the memory #137

Closed AlenToma closed 2 years ago

AlenToma commented 2 years ago

Hi, As I am new to this libray. I really need help understading how this really work.

Say I am using this to save some data for 1hr. Will the data be cleared after one hour? Or is the data still there and will be able to renew it if the method with the same data and parameter is called again?

There should be something like a timer where it will clear old items. At least I hop there is, becouse my app crash after I am having it open for one to tow days and I thing that this is coused by it using to much memory.

Could you please explain as I may have to create my own handler if it dose not have it already.

vlio20 commented 2 years ago

Hi @AlenToma, can you provide some code?

AlenToma commented 2 years ago

Please check out this thread as I mentioned my problem there(code inc) https://stackoverflow.com/questions/71476666/react-native-app-uses-to-much-memory-as-time-increase

vlio20 commented 2 years ago

Can you monitor the number of items in your custom cache or the size of it? Also you didn't show how are you creating this cache

AlenToma commented 2 years ago

I am trying to do that here

 validate() {
        var counter = this.clearSize;
        if (this.loadedFiles.size > this.maxItems)
            for (var key of this.loadedFiles.keys()) {
                counter--;
                this.loadedFiles.delete(key);
                if (counter <= 0)
                    break;
            }
    }

and this is how its it created

export class ServiceOperations {
    public FilesToRemoves: CustomCache = new CustomCache(1000, 15);
    public DownloadCache: CustomCache = new CustomCache(1000, 15);
    public HttpClientCach: CustomCache = new CustomCache(1000, 300);
    public Promises: CustomCache = new CustomCache(1000, 300);
    public DownloadTasks: any = {};
    public Console = new PrivateConsole();
    public Watcher: CustomCache = new CustomCache(1000, 300);
}
const serviceTempData = new ServiceOperations();
AlenToma commented 2 years ago

Never mind, I found the issue and it is with sqlight, as I do onscroll and update the db very much. it builds in memory then

vlio20 commented 2 years ago

@AlenToma happy you found the issue. Would appreciate if you could ⭐ this repo :)