The attached patch makes PhaseChanger shut down the engine, instead of shutting down each database individually, at the end of each phase. This made the upgrade test run again on phoneME in my environment.
I had hoped that a change like this would reduce the memory usage on Java SE too, but that doesn't seem to be the case, because the old versions of the driver (and thereby all the engine classes) is still referenced from the DriverManager. (There's no DriverManager in JSR-169, that's why it's not a problem on phoneME.) It might possibly be solved by deregistering the driver manually, but there's some trickiness involved because of the upgrade tests' use of special class loaders to load the old Derby versions and DriverManager not allowing the deregistering of drivers registered in other class loaders, so I'm not addressing that issue right now.