How do clean resources?

Hi,

I am using ESP32, actually I have created init_lvgl() to initialize the all the parameters to start the device. As the device will use the display mainly, during the starting period, and I want to keep it deinit to save the heap and init it again only when needed, I tried to clean all the initialized parameters in init but its not cleaning properly the memory.

Just want to know whether what I want to achieve is possible?