Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

refactor: remove unnecessary gc.collect() calls

LearningCircuit68a8ef3c5cfb
diff --git a/src/local_deep_research/web/routes/research_routes.py b/src/local_deep_research/web/routes/research_routes.py
index 0c5548a95f..3061c95053 100644
--- a/src/local_deep_research/web/routes/research_routes.py
+++ b/src/local_deep_research/web/routes/research_routes.py
@@ -1575,15 +1575,11 @@ def upload_pdf():
processed_files = 0
errors = []
- # Import gc for explicit memory cleanup after each file (issue #1176)
- import gc
-
for file in files:
if not file or not file.filename:
errors.append("Unnamed file: Skipped")
continue
- pdf_content = None
try:
# Read file content (with disk spooling, large files are read from temp file)
pdf_content = file.read()
@@ -1597,10 +1593,6 @@ def upload_pdf():
if not is_valid:
errors.append(f"{file.filename}: {error_msg}")
- # Release memory immediately on validation failure
- del pdf_content
- pdf_content = None
- gc.collect()
continue
# Extract text and metadata in single pass (performance fix)
@@ -1608,10 +1600,6 @@ def upload_pdf():
pdf_content, file.filename
)
- # Release PDF content memory immediately after extraction
- del pdf_content
- pdf_content = None
-
if result["success"]:
extracted_texts.append(
{
@@ -1629,16 +1617,11 @@ def upload_pdf():
logger.exception(f"Error processing {file.filename}")
errors.append(f"{file.filename}: Error processing file")
finally:
- # Ensure memory is released after each file
- if pdf_content is not None:
- del pdf_content
# Close the file stream to release resources
try:
file.close()
except Exception:
pass
- # Force garbage collection after each file to keep memory bounded
- gc.collect()
# Prepare response
response_data = {