One good way to keep track of it all is to analyze the song on a more macro scale. If you look at the overall form of the song and identify the tonal centers (keys), you should be able to make a sort of road map. A lot of Jazz tunes will use II-V-I progressions to move from key to key. Instead of identifying each individual chord, you can begin to identify tonal centers and their structures. Memorizing the general motion from key to key should give you less to be remembering on the whole. This will also give you an idea of the harmonic structure of the song that you may be able to use to identify where you are when you get lost in a tune. You can basically try to determine where the I is in each tonal center and commit that placement to memory and when you get lost, you can listen for the resolution to I in a given tonal center.
This is clearly a little harder to do if you're the chordal instrument in the group or if the chordal instrument is the one taking the solo but, as others have mentioned, an experienced player will be choosing their melodic lines based on the structure of the song, so to some extent or another, you should be able to hear them resolving melodically in the same way. This of course does not account for when people play 'outside', so it's not a sure fire bet but can help to some extent.
You can also listen to the drums and try to follow their phrasing. This is a lot easier with some drummers than others, such as those that clearly spell out the downbeats with a crash cymbal or regularly fill at the end of phrases, which is a lot more common with beginners of Jazz. It becomes a lot more difficult when you're playing with 'heady' Jazz drummers. They tend to play around the beat just as often as they play within it and often place accents and fills in different places than beginners.
I would also suggest practicing soloing in specific phrases. Take 4 bars at a time and loop it up so that you can practice all sorts of different rhythms and melodic contours while trying to stay within the 4 bars. Then try to practice odd phrases against that, such as 3 bar phrases or 5 bar phrases, or maybe a 3 bar phrase followed by a 5 bar phrase, and try to keep track of where you are within that 4 bar loop. You can then expand this to 8 bars or whatever else makes sense. This should help you develop a stronger sense of time in the long term, as in overall phrases, and help you get more in touch with how the melodic and rhythmic ideas that come to you fit into these phrases. Feeling a form can end up being the same as feeling a measure. I'm sure we can all relate to early attempts at improv and not being able to stay within the measure while trying new things, so developing a strategy to feel the form can eventually lead to the same proficiency as feeling a measure.
Ultimately the easiest way to recover from getting lost in the form is to know the song really, really well, or at least the framework of it. A more advanced ear will help you locate yourself once you a more familiar with the tune. It can also be really helpful to be more familiar with the other players and their styles but that tends to be more difficult in Jazz, where a lot of Jazz gigs are just a few cats, that maybe even never met before, playing standards from the Real Book. If you know that you are more likely than the others that you're playing with to get lost, I would recommend mentioning it to them and asking that they try to give you an obvious signal of where you are in a song when you look to them with a sense of undying despair.