Pass a limit to BackLinkCache::getNumLinks() in some places to avoid OOMs.

Change-Id: Idf1042c083837a9e4a380bb20ecdf3043ea9ab09
(cherry picked from commit 97b66aef1728ba9f978dc55411a9400cd86b9b2f)