Particle trapping by nonlinear resonances and space charge