DFS uses memory for the adjacency list, the visited array, and the recursion call stack. The adjacency list takes space. The visited array takes . The call stack depth equals the longest path you explore before backtracking.
In the worst case (a long chain graph), this is . So total space is for the graph storage plus for the recursion stack. If you use iterative DFS with an explicit stack, the stack space is still worst case.