GUI
This commit is contained in:
@@ -20,11 +20,27 @@ class PCAPLoader:
|
||||
self._packet_count: Optional[int] = None
|
||||
|
||||
def load_all(self) -> List[Packet]:
|
||||
"""Load all packets from the PCAP file"""
|
||||
"""Load all packets from the PCAP file with memory management"""
|
||||
try:
|
||||
# Check file size and warn for large files
|
||||
import os
|
||||
file_size = os.path.getsize(self.file_path)
|
||||
if file_size > 100 * 1024 * 1024: # > 100MB
|
||||
print(f"Warning: Large PCAP file ({file_size / (1024*1024):.1f} MB)")
|
||||
print("Consider using streaming mode for better memory management")
|
||||
|
||||
# Force garbage collection before loading
|
||||
import gc
|
||||
gc.collect()
|
||||
|
||||
packets = rdpcap(self.file_path)
|
||||
self._packet_count = len(packets)
|
||||
|
||||
print(f"Loaded {len(packets)} packets ({file_size / (1024*1024):.1f} MB)")
|
||||
return packets
|
||||
|
||||
except MemoryError:
|
||||
raise IOError(f"Out of memory loading PCAP file {self.file_path}. Try using streaming mode.")
|
||||
except Exception as e:
|
||||
raise IOError(f"Error loading PCAP file {self.file_path}: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user