Integral of a non negative function over an infinite interval. If $f(x) \geq 0$ and for every $x \in [0, \infty)$, $f(x)$ is Riemann integrable on $[0,n]$ for all n. If $\int_{0}^{\infty}f(x)dx < \infty$ then is it true that $\lim_{x \rightarrow \infty}f(x) = 0$. If yes then how? 
 A: Consider something like
$$ f(x) = \begin{cases} 1 & n< x < n+2^{-n}, \quad n \in \mathbb{N} \setminus \{0\} \\ 0 & \text{else} \end{cases}. $$
Then
$$ \int_0^{\infty} f(x) \, dx = \sum_{n=1}^{\infty} (n+2^{-n}-n) = 1, $$
but $f(x)$ is equal to $1$ for a set of $x$ including arbitrarily large reals.
A: To elaborate on David Mitra's comment: 
Define $T(x) = \begin{cases}1-|x| & \text{if} \ |x| < 1 \\ 0 & \text{if} \ |x| \ge 1\end{cases}$ and let $f(x) = \displaystyle\sum_{n = 1}^{\infty}T\left(\dfrac{x-n}{n^2}\right)$. 
Note that $T(x)$ is a piecewise linear function which connects $(-1,0)$ to $(0,1)$ to $(1,0)$. This spike has width $2$ (centered at $0$) and height $1$, so the area underneath $T(x)$ is $1$. 
Then, $T\left(\dfrac{x-n}{n^2}\right)$ is $T(x)$ squished horizontally by a factor of $n^2$ and then translated to the right by $n$. Hence, $T\left(\dfrac{x-n}{n^2}\right)$ is a spike which has width $\dfrac{2}{n^2}$ (centered at $n$) and height $1$, so the area underneath $T\left(\dfrac{x-n}{n^2}\right)$ is $\dfrac{1}{n^2}$. Also, each of the $T\left(\dfrac{x-n}{n^2}\right)$'s are non-overlapping. 
Hence, $\displaystyle\int_{0}^{\infty}f(x)\,dx = \displaystyle\int_{0}^{\infty}\sum_{n = 1}^{\infty}T\left(\dfrac{x-n}{n^2}\right)\,dx = \sum_{n = 1}^{\infty}\int_{0}^{\infty}T\left(\dfrac{x-n}{n^2}\right)\,dx = \sum_{n = 1}^{\infty}\dfrac{1}{n^2} < \infty$. 
However, $f(n) = 1$ for each integer $n$, so $\displaystyle\lim_{x \to \infty}f(x) \neq 0$. 
Note: We could also have a function, like $f(x) = \displaystyle\sum_{n = 1}^{\infty}nT\left(\dfrac{x-n}{n^3}\right)$, for which $\displaystyle\int_{0}^{\infty}f(x)\,dx < \infty$ but $f(x)$ is unbounded as $x \to \infty$.
