Growth restriction for nonnegative, continuous functions whose integrals on $\mathbb{R}$ are bounded When we have a nonnegative, continuous function $f(x)$ whose integral over all real numbers $\mathbb{R}$ is bounded, like: $$\int_{-\infty}^{\infty}f(x)dx  = A< \infty $$ with $A \in \mathbb{R}$ what kind of growth restrictions should it have? Intuitively $\lim_{x \to\infty}f(x) =0$ and $\lim_{x \to -\infty}f(x) =0$ come to my mind for example, but I don't know whether they are correct. 
 A: It is not correct that $\lim_{x \to \infty} f(x) = 0$. In fact, you can even cook things up so that there is an unbounded, increasing subsequence of points for which $f(x_n) \to \infty$. What you need to do is take a collection of intervals of decreasing width on which the function gets larger and larger, and let the function be zero elsewhere. If you make the widths shrink much faster than the function grows, the integral can essentially be computed as an infinite, convergent sum.
If you want an even more simple example, you can just let the function be defined by $f(n) = n$ for $n \in \mathbb{Z}$ and $f(x) = 0$ otherwise. Then the integral is zero but neither of those limits are.
The moral here is that if you know the integral is finite you cannot control how big the function gets without also thinking about how often that happens, and how rapidly it might shrink elsewhere. The limit is a delicate object that is not sensitive to the the size of the interval on which the function is big. A set of arbitrarily small width can provide a counterexample to your claim about the limit, but it will have very little impact on the value of the integral itself.  
A: For a continuous (or even smooth) example, start with any function $\phi$ which is continuous (or smooth), nonnegative, zero outside $[-1/2, 1/2]$, and whose integral is 1.  (For a continuous function, a triangle will work.  For a smooth function, use a bump function).  Then let
$$f(x) = \sum_{n=0}^\infty 2^n \phi(4^n x - n).$$
It will help to draw yourself a picture.  Roughly, you have a bump at each integer; each bump has 2 times the height and 1/4 the width of the previous one, so it has 1/2 the area.  When you sum up all the areas, you get a convergent geometric series.  But since the heights of the bumps keep increasing, $\limsup_{x \to \infty} f(x) = +\infty$ while $\liminf_{x \to \infty} f(x) = 0$.  
A: [If you assume $f$ to be continuous then it is necessary that $f$ vanishes at infinity. This is false, as Nate pointed out in the comments.]
But this is not sufficient: consider $1/(1+|x|)$. Sufficient: if $f\in\mathcal{S}(\mathbf{R})$ lies in the Schwartz space (e.g. if $f$ has compact support or is a relative of $\exp(-x^2)$), or more generally if that $f$ grows moderately, i.e. there is a constant $C$ such that $f$ is in absolute value bounded by $C/(1+x^2)$.
