INSIDE YOUR DELL OPTIPLEX 5040 - MICRO TOWER. Kit Capacity: 8GB. Your PC has 4 Slots and can be upgraded to 32GB (4x8GB).
eBay