Deactivate Mesh Renderer when not visible by camera

Hello,
In order to save memory I would like to disable set of mesh Renderers of gameObject that is not visible by the camera. So far I have the below script:

private MeshRenderer rend;
  

     void Start()
     {
         rend = GetComponent<MeshRenderer>();
     }   


public void OnBecameVisible()
     {
         rend.enabled = true;
     }


     public void OnBecameInvisible()
     {
         rend.enabled = false;
     }

OnBecameInvisible() is being called but OnBecameVisible() is only being called once? Is it because the mesh renderer is off? If so, is there any other solution to get it back on?

Disabling something generally sets a flag somewhere. That will generally not affect your consumed memory. I mean it might, but I would first try to identify if it does before going too far down the rabbit hole in order to avoid writing a lot of code that will not actually solve your problem.

As for why the OnBecame calls are not happening, not sure because I haven’t tinkered with that endpoint myself.

Most likely because it will be called only once since the meshRenderer is turned off