In main, resources were freed on the success path but not in the error path. This change ensures all allocated resources are released before returning.
`speedPerRound` is allocated at the start of benchMem to collect per-round speeds, but is never freed, causing a leak on each invocation.