@@ -201,8 +201,10 @@ def plot_cell_diagnostics(c_idx, cell_sa, ampls_sa, dat_2D_sa, output_dir, param
201201 plt .savefig (output_path , dpi = 150 , bbox_inches = 'tight' )
202202 plt .close (fig )
203203
204- # Explicit memory cleanup
204+ # Explicit memory cleanup - delete ALL objects to prevent memory leaks
205205 del fig , axs , fig_obj , im1 , im2 , topo_original , dat_2D_masked
206+ del cbar1 , cbar2 , norm , topo_cmap , diff
207+ gc .collect () # Force garbage collection after plotting
206208
207209 logger .info (f" Plot saved: { output_path } " )
208210
@@ -789,7 +791,18 @@ def parallel_wrapper(grid, params, reader, writer, chunk_output_dir, clat_rad, c
789791
790792 # Create new client with appropriate memory configuration
791793 n_workers = batch_config ['n_workers' ]
792- memory_per_worker = f"{ int (batch_config ['memory_per_worker_gb' ])} GB"
794+
795+ # ============================================================
796+ # MEMORY CONFIGURATION
797+ # ============================================================
798+ # If only 1 worker, allow it to use ALL available memory
799+ # This is critical for high-memory polar cells (>60 GB)
800+ if n_workers == 1 :
801+ memory_per_worker = f"{ int (total_memory_gb )} GB"
802+ logger .info (f"\n Single-worker mode: allowing full memory access ({ total_memory_gb } GB)" )
803+ else :
804+ memory_per_worker = f"{ int (batch_config ['memory_per_worker_gb' ])} GB"
805+ # ============================================================
793806
794807 # ============================================================
795808 # THREADS PER WORKER CONFIGURATION
0 commit comments