When I try to understand a theoretical opening position, I set up that position in the analysis board and open the opening explorer (masters' database ofc). I then load the top games in new tabs (sometimes only the decisive top games or even only those where the colour won that I intend to play the position with) and trigger the engine analysis on them. Next, I play all polular half-moves and all half-moves that score particularly well and repeat the procedure for all of them. Additionally, if there's a move that feels natural to me, but was neither one of the popular ones nor one of the well-scoring ones, I try to find out what's wrong with it. (Usually by using a combination of my brain, the local engine analysis and by checking games in which that move was played - if there are any.)
Once I feel like I have collected enough games (there can quickly be 20 or more games after just a few moves), I start playing through all of them. This way, I get a feeling for the kind of positions that arise out of the opening I wanted to study.
Now, I'm not able to memorize everything just from playing through those games, but usually, the more popular lines actually do find their way into my memory this way. :)
But memorizing deep lines isn't that important anyway as most opponents will not go into them. What's more important is that you understand each single half-move and that you understand the often subtle differences between alternative moves in a given position.
Once you play a game in an opening that you spent just some time studying on, it's already quite likely that your opponent will be the one leaving theory by playing a "novelty" (or simply an inferior move...) If it's a longer game where you have time to think, try to understand what your opponent's idea is, check if he has created an immediate threat and otherwise just try to find a reason why his move might be inferior to the book moves. :p
One example from a club championship game I played yesterday:
I played the 3. Nf3 Scandi with white (because the 3. Nf3 Scandi is awesome), and my opponent played 3. ... Bg4 4. Be2 Nf6. I only knew the move 4. ... Nc6 with the idea of 0-0-0, putting pressure on d4. In that case, white typically goes for d4, c4, 0-0 and sacs the d4 pawn for an initiative / quick attack on black's king while black is busy developping all of his pieces.
Now what should I do against the (to me) unfamiliar move 4. ... Nf6 then? I paused, figured that black hadn't created any threat and probably didn't know the 3. Nf3 Scandi that well after all. So, I continued with the natural plan of playing d4 and c4 (the whole point of omitting an early Nc3) and enjoyed the fact that I wouldn't have to sac my d pawn because black got no pressure on it. After 8 moves, I basically got a very comfortable version of a Caro-Kann / French Rubinstein structure and went on to win.
So, what basically helped me in this game was not deep knowledge of one particular line, but knowing the general idea of the 3. Nf3 Scandi: To play d4 and c4 before putting a knight on c3.
Here's the game (chapter 3):
lichess.org/study/D3lufrHL (Note that there are still some minor flaws in the analysis as I wrote my annotations before checking with the engine. - I'll try to fix that within the next few days.)