  We show how dynamic heterogeneities (DH), a hallmark of glass-forming
materials, depend on chain flexibility and chain length in polymers. For highly
flexible polymers, a relatively large number of monomers ($N_c\sim500$) undergo
correlated motion at the glass transition temperature $T_g$, independent of
molecular weight ($M$). In contrast, less flexible polymers show a complex
$N_c(M)$ behaviour divided into three regimes, consistent with observation in
both $T_g(M)$ and chain conformational structure. For short oligomers
($\lesssim$ 2 Kuhn steps), a transition from mainly $\it{inter}$molecular
correlations and $N_c\sim 200$, to strongly $\it{intra}$molecular correlations
and $N_c< 50$ (roughly the molecular size) is observed; for longer chains,
$N_c$ increases weakly, before saturating. For poly(methyl methacrylate), a
remarkable similarity is found between $N_c(M)$ and the $M$-dependent ratio of
the activation barriers of the structural ($\alpha$) and secondary ($\beta$)
relaxations. Our results suggest a link between the DH length-scale and the
number of $\beta$ relaxation events jointly-activated to facilitate the
$\alpha$ relaxation.
