Give an example of a continuous function $f : [0, ∞) \to [0, ∞)$ such that $\int_{0}^{\infty}f(x)dx$ exists but $f$ is unbounded. Give an example of a continuous function $f : [0,  ∞) \to [0, ∞)$ such that  $\int_{0}^{\infty}f(x)dx$ exists but  $f$ is unbounded.
I have been thinking about this. And I have come to the conclusion that I will need to construct a function, $f$, such that $f$ is a sequence of triangles of increasing height, but decreasing base.
I obviously need $f$ such that both the height of the triangles and the sum of the bases tend to infinity.
But I also need that the $\sum (\text{height} \times \text{base}) \leq \infty $
 A: Building off your idea, but allowing most of the triangles to have zero height (otherwise it will not converge): Choose some divergent series. I'll assume we're dealing with the harmonic series $\sum \frac{1}{n}$. The nth triangle will have base $\frac{1}{n}$.
Now in general, start with $f \equiv 0$, i.e. suppose the general triangle we have is degenerate. But let the $2^n$th slot have a triangle of height $2^{n/2}$.
Or more generically: have some shape that has area $1$ from $0$ to $1$, then some shape that has area $\frac{1}{2}$ from $1$ to $2$, $\frac{1}{4}$ from $2$ to $3$, smoothing as necessary. You can make your function $0$ as much as you want, but you need to make your shapes get taller. You can think of fitting a triangle of height $k$ in the $k$th slot, making the base the necessary width to give area $\frac{1}{2^k}$ in that slot.
You can do many more along these lines.
A: Successive triangles is definitely the way to go (for example, choosing the $n$th triangle centered at $n$ with height $n$ and width $1/n^3$ does the job) but mixtures of distributions provide regular examples which are rather natural (to probabilists, at least...). Thus, consider
$$
f(x)=\sum_{n\geqslant1}n\,\varphi(n^3(x-n))\cdot\mathbf 1_{x\geqslant0},
$$
where $\varphi$ is any multiple of any regular PDF such that $\varphi(0)\ne0$, for example,
$$
\varphi(x)=\mathrm e^{-x^2}.
$$
Then $f(n)\geqslant n\varphi(0)$ hence $f$ is unbounded at infinity, the function $f$ is smooth, its support is the full halfline $[0,+\infty)$, and $f$ is integrable since
$$
\int_0^\infty f(x)\,\mathrm dx\leqslant\int_\mathbb R\left(\sum_{n\geqslant1}n\,\varphi(n^3(x-n))\right)\,\mathrm dx=\sum_{n\geqslant1}\frac1{n^2}\cdot\int_\mathbb R\varphi(x)\mathrm dx.
$$
A: Consider the function $$f(x)=x^2\exp(-x^8\sin^2 x)$$
as seen here. 
A: I had the same desire expressed in dfeuer's comment.  
From the answers to Integral of $\cos^{n}(x)$ on $[0,2\pi]$ for $n$ a positive integer and Stirling's approximation we get $$\int_0^{2\pi}\cos^{2n}x\,dx\sim\dfrac{2\sqrt\pi}{\sqrt n}.$$  Using this fact, we can show that $f(x) =  x |\cos x|^{x^5}$ is an example.  Note that $$\int_0^\infty f(x)\,dx=\sum\limits_{k=0}^\infty\int_{2\pi k}^{2 \pi(k+1)} x|\cos x|^{x^5}\, dx.$$ Because $t\mapsto t$ is increasing and $t\mapsto |\cos x|^t$ is decreasing for each $x$, we can bound each summand as follows:
$$\begin{align*}
\int_{2\pi k}^{2 \pi(k+1)} x|\cos x|^{x^5}\, dx
& \leq\int_{2\pi k}^{2\pi(k+1)} 2\pi(k+1)|\cos x|^{(2\pi k)^5}\,dx\\
& \leq 2\pi(k+1)\int_{2\pi k}^{2\pi(k+1)}|\cos x|^{2k^5}\,dx\\
&= 2\pi(k+1)\int_{0}^{2\pi}\cos^{2k^5} x\,dx\\
&\sim \dfrac{C}{k^{3/2}},
\end{align*}$$
where the last step follows from the afore mentioned result, and $C$ is a constant independent of $k$.  Hence $\int_0^\infty f(x)\,dx<\infty$.
A: Building up on the idea of triangles presented by many users, I have found a simple enough function...
The idea is that the bases of the triangles, when taken as a series should diverge to $\infty$, while the individual terms converge to $0$. But the series of areas of triangles should converge to some finite quantity. One natural candidate for the bases of triangles is the sequence $1/n$.
Then $\sum 1/n > \infty$, and taking the heights to be $\sqrt{n}$ (with alternating signs of course), we get the areas to be $$\dfrac{1}{2},-\dfrac{1}{2\sqrt{2}},\dfrac{1}{2\sqrt{3}},-\dfrac{1}{2\sqrt{4}} \cdots$$
It is well known that the series $\sum (-1)^{n+1}\left(\dfrac{1}{\sqrt{n}}\right)$converges and so we are done.
Image for reference
A: Let $f= \cases{ x^{-1/2} , & $[0,1)$ \\ x^{-2} , & $[1,\infty )$ }$, then $\int_0^\infty f(x)dx = 3$. Is that what you are looking for?
EDIT: In the spirit of mixedmath: Let $Tr(x,h,w)=\max (1-|2x/w -1| , 0 )h$. Then let $h_i=i^{1/4}$ and $w_i=1/i^{2+1/4}$. Let $f=\sum_{i=1}^\infty Tr(x-i,h_i,w_i)$ such that 
\begin{equation}
\int_0^\infty f(x) dx = \int_0^\infty\sum_{i=1}^\infty Tr(x-i,h_i,w_i) dx= 1/2\sum_{i=1}^\infty i^{-2}=\pi^2/12
\end{equation}
with questionable convergence.
