6. Given positive integers $x_{1}, x_{2}, \cdots, x_{10}$ satisfying $x_{1}<x_{2}<\cdots<x_{10}$,
and $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2} \leqslant 2009$.
Then the maximum value of $x_{8}-x_{5}$ is ( ).
(A) 17
(B) 18
(C) 19
(D) 20
6. B.
$$
\begin{array}{l}
\text { Clearly } x_{i} \geqslant i(i=1,2, \cdots, 7), \\
x_{8}+1 \leqslant x_{9}, x_{8}+2 \leqslant x_{10} .
\end{array}
$$

From the problem, we have
$$
\begin{array}{l}
1^{2}+2^{2}+\cdots+7^{2}+x_{8}^{2}+\left(x_{8}+1\right)^{2}+\left(x_{8}+2\right)^{2} \\
\leqslant 2009 .
\end{array}
$$

Simplifying, we get $x_{8}^{2}+2 x_{8}-621 \frac{1}{3} \leqslant 0$. Then $\left(x_{8}+1\right)^{2} \leqslant 622 \frac{1}{3}<625$.
Thus, $x_{8}<24$.
Therefore, the maximum value of $x_{8}$ is 23.
So, the maximum value of $x_{8}-x_{5}$ is $23-5=18$.