$T_1$ spaces where the closure of a compact set is not compact

Here is a broad generalization of your example which perhaps makes it appear more natural. Given a topological space, you can add any number of "copies" of any of its points, the same way that you build the "line with doubled origin" from $\mathbb{R}$ by adding another copy of $0$.

To be precise, suppose $A$ is a topological space, $B$ is a set, and $f:B\to A$ is a function. Then we can define a topological space $X=A\sqcup B$ with the following topology: a set $U\subseteq X$ is open iff $U\cap A$ is open in $A$ and for each $x\in U\cap B$, $U$ contains a deleted neighborhood of $f(x)$ in $A$. (The idea here is that each $x\in B$ represents a new "copy" of the point $f(x)\in A$; if $A=\mathbb{R}$, $B$ is a singleton, and $f$ maps the point of $B$ to $0$, then $X$ is exactly the line with doubled origin).

Now suppose additionally that $A$ is a compact $T_1$ space, $B$ is infinite, and $f(x)$ is not isolated in $A$ for each $x\in B$. Then $X$ is also a $T_1$ space, and $A$ is a compact subset of it. Moreover, since $f(x)$ is not isolated for all $x\in B$, the closure of $A$ in $X$ is all of $X$. But $X$ is not compact, since for each $x\in B$, the set $A\cup\{x\}$ is open, and these form an open cover with no finite subcover.

In other words, if we take a compact $T_1$ space and add infinitely many "copies" of non-isolated points, we get an example of a $T_1$ space with a compact subset whose closure is not compact. Your example is just the special case of this where you start with an infinite set with the cofinite topology (in that case, the function $f$ doesn't matter since all points have the same deleted neighborhoods).


Let $X=\Bbb N \cup A$ where $A$ is some non-empty set disjoint from $\Bbb N$, with at least two elements. A basic neighbourhood of $n \in \Bbb N$ is $\{n\}$ (so is an isolated point), while a basic neighbourhood of $a \in A$ is $\{a\} \cup (\Bbb N \setminus F)$ where $F \subseteq \Bbb N$ is finite.

Then it's easily checked that $X$ is $T_1$, that any two neighbourhoods of $a \neq a'$ in $A$ intersect (so $X$ is not $T_2$) and that $N_a:=\Bbb N \cup \{a\}$ is compact for every $a \in A$ and for all $a$, $\overline{N_a}=X$ and $X$ is not compact if $A$ is infinite (as $A$ is a closed discrete subspace of $X$). So this gives an example.