In R.D. Richtmyer, Principles of Advanced Mathematical Physics, p.85 an example is given of a continuous and square-integrable on $\bf{R}$ function, which is not bounded at infinity:
$$f(x)=x^2\exp{(−x^8\sin^2{x})}.$$
Intuitively, it can be expected that $f(x)$ is square-integrable as its peaks become more and more narrow. But how can one rigorously prove that $f(x)$ is indeed square-integrable?



Square-integrable unbounded function
For $k=1,2,\dots$, let 
$$I\_k:=\int\_{|x-k\pi|<1/k}f(x)^2\,dx
=\int\_{|x-k\pi|<1/k}x^4\exp(-2x^8\sin^2 x)\,dx.$$
Then, as $k\to\infty$,
$$I\_k\asymp k^4\int\_{|x-k\pi|<1/k}\exp\{-(2+o(1))(k\pi)^8\sin^2 x\}\,dx \\
=k^4\int\_{|x|<1/k}\exp\{-(2+o(1))(k\pi)^8\sin^2 x\}\,dx \\
=k^4\int\_{|x|<1/k}\exp\{-(2+o(1))(k\pi)^8 x^2\}\,dx \asymp1,$$
by substitution $u=(k\pi)^4 x$. 
(Here we use the usual notation: $A\asymp B$ meaning $A=O(B)$ and $B=O(A)$.)
Hence, 
$$\int\_{-\infty}^\infty f(x)^2\,dx\ge\sum\_{k=1}^\infty I\_k=\infty.$$
So, $f$ is actually not square-integrable. 




---


Reasoning similarly (but using, say, $h\_k:=1/k^{b/3}$ instead of $1/k$ in $|x-k\pi|<1/k$), one can see that for any real $a,b>0$, letting 
$$f(x):=|x|^a\exp(-|x|^b\sin^2x),$$
we have the following: 


1. $f$ is continuous, but unbounded at $\infty$.
2. $f$ is square-integrable iff $2a-b/2<-1$.


To get this result, we also note that for $k=1,2,\dots$
$$\int\_{h\_k\le|x-k\pi|\le\pi}x^{2a}\exp(-2x^b\sin^2 x)\,dx \\ 
=O(k^{2a}\exp\{-(2+o(1))(k\pi)^b h\_k^2\})=O(1/k^c)$$
for any real $c$.




---


In your example, we have $a=2$ and $b=8$, so that $2a-b/2=0\not<-1$, and so, your $f$ is not square-integrable. 


