How to use ImageManager.loadPicture("")

So, since I don't want images to lag when they show, I often use this:

ImageManager.loadPicture("coolimage")

to preload my images.
I notices that when I start my game, after a while of playing, the Computer's memory seems pretty exhausted, and I suspect that there are some images constantly loading!?

So I wanted to ask: What is the proper way to handle image cache? Is it required to "empty" the cache after a while?
2 questions:
  1. When are you calling the loadPicture method? (in an event? In a loop?)
  2. What do you mean by "the Computer's memory seems pretty exhausted".
Loading a picture into the cache once shouldn't be resource intensive. If it is, I would suspect you're calling the method inside a loop.
I notice the problem with image lag as well.
I only need to call event show pictures for every possible image I'm going to use on that map ONCE, then erase it (of course I masked this action with fade out). By default, RM will automatically chace those images.
I maybe found a manual workaround for this after running into it myself.
I used a plugin and skipped the title screen and when pushing buttons up and down it would show different pictures for "new game,load,credits,end".
The first time when loading those pictures there would be a slight display hick up which many maybe describe as lag.
After the first hickup for each individual Picture, they worked flawlesly.

To workaround that, i faded out the screen and showed every picture for 1frame with whatever pic id you want, the pictures work with every id after manual preload, than changing title command pictures on my title screen worked fine.

I did not test if those work for the whole game or are deleted after mapchange (which i assume).
Javascript is garbage collected and the image cache stores only up to X pixels, where X is defined inside the community basic plugin. So you shouldn't have a problem with the image cache. If memory is full, that means there might be a memory leak somewhere, but full memory doesn't cause lag, it causes crashes as Win10 tries to free up some RAM.
and if you want to load only when they should, why not using galv_ImageCache?

Original thread: https://forums.rpgmakerweb.com/threads/how-to-use-imagemanager-loadpicture.112984/