How to optimize 2D tilemaps by using chunks

Godot Version

4.3

Question

so im making a metroidvania(platformer) but the tilemap is really big and can cause performance issues on other devices. so i thought to make a chunk system(every tile outside the screen will be hidden/queue_free() but i dont know how.

if you know the answer, pls reply and if it has some things that are no code, pls post a screenshot. thanks!

for every “chunk” create one tilemap and and then just show/load the chunks that are close to the player

that will also make it lagy because of the big amount that a chunks dhould have.what i actually want is that ecery tile that isn’t on the screen gets deleted and if it enters the screen again it shows again