Commit 
							
							·
						
						7032e51
	
1
								Parent(s):
							
							f20bd02
								
fix memory leak
Browse files
    	
        vms/services/monitoring.py
    CHANGED
    
    | @@ -223,6 +223,7 @@ class MonitoringService: | |
| 223 | 
             
                    Returns:
         | 
| 224 | 
             
                        Matplotlib figure with CPU usage plot
         | 
| 225 | 
             
                    """
         | 
|  | |
| 226 | 
             
                    fig, ax = plt.subplots(figsize=(10, 5))
         | 
| 227 |  | 
| 228 | 
             
                    if not self.timestamps:
         | 
| @@ -268,6 +269,7 @@ class MonitoringService: | |
| 268 | 
             
                    Returns:
         | 
| 269 | 
             
                        Matplotlib figure with memory usage plot
         | 
| 270 | 
             
                    """
         | 
|  | |
| 271 | 
             
                    fig, ax = plt.subplots(figsize=(10, 5))
         | 
| 272 |  | 
| 273 | 
             
                    if not self.timestamps:
         | 
| @@ -312,6 +314,7 @@ class MonitoringService: | |
| 312 | 
             
                    num_cores = len(self.cpu_cores_percent)
         | 
| 313 | 
             
                    if num_cores == 0:
         | 
| 314 | 
             
                        # No data yet
         | 
|  | |
| 315 | 
             
                        fig, ax = plt.subplots(figsize=(10, 5))
         | 
| 316 | 
             
                        ax.set_title("No per-core CPU data available yet")
         | 
| 317 | 
             
                        return fig
         | 
|  | |
| 223 | 
             
                    Returns:
         | 
| 224 | 
             
                        Matplotlib figure with CPU usage plot
         | 
| 225 | 
             
                    """
         | 
| 226 | 
            +
                    plt.close('all')  # Close all existing figures
         | 
| 227 | 
             
                    fig, ax = plt.subplots(figsize=(10, 5))
         | 
| 228 |  | 
| 229 | 
             
                    if not self.timestamps:
         | 
|  | |
| 269 | 
             
                    Returns:
         | 
| 270 | 
             
                        Matplotlib figure with memory usage plot
         | 
| 271 | 
             
                    """
         | 
| 272 | 
            +
                    plt.close('all')  # Close all existing figures
         | 
| 273 | 
             
                    fig, ax = plt.subplots(figsize=(10, 5))
         | 
| 274 |  | 
| 275 | 
             
                    if not self.timestamps:
         | 
|  | |
| 314 | 
             
                    num_cores = len(self.cpu_cores_percent)
         | 
| 315 | 
             
                    if num_cores == 0:
         | 
| 316 | 
             
                        # No data yet
         | 
| 317 | 
            +
                        plt.close('all')  # Close all existing figures
         | 
| 318 | 
             
                        fig, ax = plt.subplots(figsize=(10, 5))
         | 
| 319 | 
             
                        ax.set_title("No per-core CPU data available yet")
         | 
| 320 | 
             
                        return fig
         | 
