After racking his brains and getting nothing, it was truly a waste of effort.
Tips
usage
费尽心机 often carries a slightly negative connotation — implying cunning or calculating effort rather than honest hard work. Compare 绞尽脑汁 (to rack one's brains) which is more neutral. Use 费尽心机 when scheming or manipulation is implied.
memory
费 (to expend) + 尽 (to exhaust) + 心机 (mental schemes) = to exhaust all your mental machinations.