vlio20/utils-decorators

Timer, to clear the memory

AlenToma opened this issue · 6 comments

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.

Hi @AlenToma, can you provide some code?

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

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

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();

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

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