Problems when displaying BMP images from SD card one after the other

Description of the problem: There are 5 BMP images on the SD card. A new image is read and displayed in the loop every 8 seconds.
With the first image «img_blau _ ###########. Bmp», the sequence between 0.7 and <8.7 seconds is called up by LVGL. With the second picture «img_gruen _ $$$$$$$$$$$$. Bmp», a sequence between 8.7 and <16.7 seconds is called up. It should be noted that «img_blau _ ############. Bmp» is also read again. In the following images, all images that have already been read are read in repeatedly. See the atachet log file.
After a while, the loop task is blocked in such a way that a picture change can only take place after a few minutes.
Question: Can or must I close a previously opened picture, if so, how?

The code:
void loop() {
lv_timer_handler();
delay(50);

if (millis() > timeNow + MAX_WAIT_IMG_CHG) {
    timeNow = millis();
    counter++;
    if (counter >= MAX_IMGS) {
        counter = 0;
    }
    lv_fs_drv_t *drive = getDriver();
    if (drive != NULL) {
        sd_close_cb(drive, getFilePointer());
    }
    /*Display Image */
    lv_obj_t *img = lv_img_create(lv_scr_act());
    lv_img_set_src(img, images[counter]);
    lv_obj_center(img);
    /* Heap Size */
    // LV_LOG_INFO("Free Heap: %i", ESP.getFreeHeap());
}

}
platformio-device-monitor-211218-160140.txt (116.4 KB)

Every time your programm reach this line it creates new image, and sets src to it. New image placed on the top and centered on the screen. To draw new image LVGL need to know picture on background, so it need to read all previous images.
Maybe try to use one image object (made lv_obj_t *img static or global). In this case your programm will manipulate with this one, just change image options.

Thanks for your feedback. I made the variable global and also static, unfortunately it didn’t help. As before, the images that were previously read are reread with each pass again. Each of the 5 images will show a heating scheme in the final application. Depending which page the user calls, the corresponding scheme must appear with additional widgets. The pictures are on the SD card because there is no space in the memory.
Is there some way to erase a previously read image so that LVGL no longer has a clue of the previously read image?

You also should leave single lv_image_create() instead of multiple call at every loop itteration. I can suggest to move lv_img_create() into setup(), and leave in loop only img configuration (lv_img_set_src, etc). In this case it will be better if lv_obj_t *img is global.

You are my super hero of the day and this just before Christmas. Now it works as expected. Many Thanks.