How to do an infinite map 2d scroller?

You can make it so that the levels have segments like so: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums

Then stream the segments in as necessary (ie. 10000 points = load ending segment in next segment to end that run).

This way you make it so there are X± segments, you want to have the levels ascend upwards (or downwards) you need Y± segments.

If you cant go backwards (like SMB1) you can dump segment 1 when it has fully left the screen however it can cause a few errors (powerups, monsters falling into the abyss) its better to do it on a 4 segment role (or 3)
of 1-2-3 into 2-3-1 into 3-1-2 that way you should be able to hold the level data in memory and dump the non required things such as powerups, monsters, positions and misc stuff.