Given $g(x)\in L^2(\mathbb{R}), \ g(x)>0$, let us consider $$M_g=\{f(x)\in L^2(\mathbb{R}):|f(x)| \le g(x)\}\subset L^2(\mathbb{R})$$
I have yet proved that $M_g$ is weakly compact in $L^2(\mathbb{R})$ and now I have to say if it is strongly compact.
A solution to this exercise considers a sequence $f_{n}(x)=\sin(nx)g(x)\in M_g$ which converges weakly, but not strongly, to $0$ and then deduces that $M_g$ is not strongly compact.
Why does it hold?
I thought that if it exists a subsequence $f_{n_k}$ converging strongly to some limit $f$, then $f$ has necessarily to be $0$ (since it has to be equal to the weak limit). But $$\lim_{n\to\infty} \int_{\mathbb{R}}(\sin(nx)g(x))^2 dx=\int_{\mathbb{R}}(g(x))^2 dx>0$$ and it holds for every subsequence.
A simple consequence of the Riemann-Lebesgue Lemma is that, if $h\in L^1$, then $$\lim_{n\to\infty}\int h(x)\cos(nx)dx=\lim_{n\to\infty}\int h(x)\sin(nx)dx=0.$$ Thus, if $\varphi\in L^2$, then since $g\varphi\in L^1$ by Cauchy-Schwarz, one has $$\int f_n(x)\varphi(x)dx=\int g(x)\varphi(x)\sin(nx)dx\to0$$ as $n\to\infty$, that is, $f_n\to0$ weakly in $L^2$. On the other hand, using $\sin^2x=\frac12(1-\cos(2x))$, one has $$\int f_n^2\,dx=\frac12\int g^2dx-\frac12\int g^2(x)\cos(2nx)dx\to\frac12\int g^2dx>0,$$ and in particular $f_n\not\to0$ strongly in $L^2$.