# MemoryError: Unable to allocate array with shape (100000000,) and data type float64

- **ID:** `python/starlette-memory-error-upload`
- **Domain:** python
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to read a large file upload into memory all at once in a Starlette/FastAPI endpoint.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (85% success)
   ```
   Stream the file using UploadFile.read(chunk_size) in a loop and process chunks: while chunk := await file.read(1024*1024): process(chunk)
   ```
2. **** (80% success)
   ```
   Use a temporary file on disk: with tempfile.NamedTemporaryFile(delete=False) as tmp: shutil.copyfileobj(file.file, tmp)
   ```

## Dead Ends

- **** — These don't affect Python's heap allocation for large numpy arrays; physical RAM is exhausted. (90% fail)
- **** — This loads the whole file into a bytes object, still causing memory pressure. (80% fail)
