Infinitive vs. present participle (time relations)
Solution 1:
Did you remember locking the door?
This question is being asked now (moment A) about whether you remembered some time in the past (moment B) if you locked the door some time further back in the past (moment C).
Did you remember to lock the door?
This question is being asked now (moment A) about whether you remembered some time in the past (moment C) to lock the door some time slightly in moment C's future (moment B).
While there's an element of the future in the second sentence, both sentences refer to events in the past of now (moment A).
Solution 2:
Neither sentence refers to the future. The difference is not so much one of time as of the different contexts in which the different forms might be used.
The first question might typically be asked after an incident such as a burglary. Anyone conducting an inquiry into the event would ask a series of questions, such as ‘Did you notice anything strange?’, ‘Did you leave anything in the house?’, ‘Did anyone else have a key?’ Your sentence, ‘Did you remember locking the door?’ would fit well with such questions, but, depending on when the inquiry took place, it would probably occur as ‘Do you remember locking the door?’
The second question might be asked when two people are leaving a house. The speaker wants to be sure that the house is properly secured, and so uses the question to check that the door has indeed been locked.
Solution 3:
Remember with a noun object means to recall something that happened in the past.
- Remember the Maine!
- I remember Mama.
- He doesn't remember it; he was too young when it happened.
Remember with a (subjectful or subjectless; and active or stative) gerund complement means to recall an action that the subject of remember performed (for active predicates), or an event that the subject of remember witnessed (for statives), in the past.
- I remember Mama making bread on our old kitchen table.
- I remember watching Mama make bread on our old kitchen table.
Remember with a subjectless active infinitive complement means the subject of remember reminds themself to do something in the future. This doesn't work with stative predicates like be tired; basically, remember to is an idiom.
- He didn't remember to put the garbage out last night.
- They will remember to lock the door after we leave.
- *He remembered to be tired after running the marathon.
Solution 4:
Both refer to the past, in different ways. The first is a bit unlikely though, possibly due to an error.
Did you remember to lock the door?
At some point in the past, you should have locked the door. That was your plan, your purpose. You would have engaged in this task; "you lock the door". But, you may have forgotten to do so! You will only have locked the door, if you remembered to. This asks whether you remembered to do so.
Possible responses:
Yes, I remembered to [lock the door].
Oh no! I forgot to lock it!
To slightly alter your first:
Do you remember locking the door?
You may or may not have engaged in the act of locking the door. If you did lock the door, you may or may not have a memory of doing so. You are being asked if you have such a memory now. That is, the question is about your present-time memory about the past time event.
I remember locking the door. (You can picture yourself when you did it, key in hand, locking the door).
I didn't lock the door. (You've no memory, because you know you didn't do it).
I don't remember locking the door. (You've no memory, but it's not impossible that you did lock it, and now forget).
So. The first is about a past memory that you were meant to do something, the second about a present memory of having done something.
Your original sentence:
Did you remember locking the door?
This asks whether, at some point in the past, you had a memory of locking the door, at some point further in the past. It's a less common construct, but does make sense in some contexts.
Why where you sure nobody would enter? Did you remember locking the door?
The main thing is that:
- "Remember + infinitive" is about an intent or purpose. "I must remember to scan over this answer for mistakes"
- "Remember + gerund" is about a completed action. "I don't remember having to learn how different verbs work when followed by infinitives or gerunds, and it can be one of the hardest things for native speakers to explain to learners".