TITLE: Infinite number of poles and residue theorem
QUESTION [8 upvotes]: I suppose a stupid question but I was wondering about it for a while:
Can one apply the residue theorem to a function $f$ which is defined and holomorphic on $U-\{a_1,a_2,\dots\}$ where $U$ is simply connected open subset of the complex plane and $a_k$ for $k\geq 1$ are all simple poles of $f(z)$. In particular I am thinking about the case when $f(z)= \Gamma(z)$, the gamma function. It is known that it has simple poles at $z=-k$, $k=0,1,2,\dots$ with resdue $(-1)^k/k!$. 
I hope the question is clear. Excuse me in case it is to trivial. I am not an expert in complex analysis.
The Wikipedia-article demands a finite number of points $a_k$. Will one get a problem with a suitable choosen closed contour?
To be more precise I would like to calculate the following integral:
$$\int_{-\infty}^{\infty} dx f(x)$$
I was wondering if the typical "trick" of constructing a closed half-circle in the upper-half plane would work too when the poles continue ad infinitum.
EDIT:
My initial motivation is to invert a Mellin transform using the Mellin inversion theorem, when the Mellin transform has an infinite number of isolated poles.
For example: I am able to show (by using a  specific symmetry of my problem) that the Melin transform of a function $P(x)$ for $0\leq x\leq x_c$ fulfills the following equation: 
$$M(s) = \frac{2x_c^s}{s-2+x_c^s}$$
where $0<x_c<1$. Now when I try to apply the Mellin inversion theorem I need to know where the poles lie. Unfortunately I think there is an infinite number poles of $M(s)$.

REPLY [4 votes]: It does work for an infinite number of singularities, as long as they are all isolated.
From Ahlfors' Complex Analysis, p.150:

$$\frac{1}{2\pi i} \int _\gamma f \ dz = \sum_{j} n(\gamma, a_j) R_j$$
  This is the residue theorem, except for the restrictive assumption that there are only a finite number of singularities. In the general case, we need only prove that $n(\gamma, a_j) = 0$ except for a finite number of points $a_j$. The assertion follows by routine reasoning. The set of points $a$ with $n(\gamma, a) = 0$ is open and contains all points outside a large circle. The complement is consequently a compact set, and as such it cannot contain more than a finite number of isolated points $a_j$. Therefore $a_j \ne 0$ for a finite number of the singularities.