diff --git a/admin_menu.module b/admin_menu.module
index abcbfeb..1a703be 100644
--- a/admin_menu.module
+++ b/admin_menu.module
@@ -778,6 +778,22 @@ function admin_menu_translated_menu_link_alter(&$item, $map) {
  *   (optional) A user ID to limit the cache flush to.
  */
 function admin_menu_flush_caches($uid = NULL) {
+  // A call to menu_rebuild() will trigger potentially thousands of calls into
+  // menu_link_save(), for which admin_menu has to implement the corresponding
+  // CRUD hooks, in order to take up any menu link changes, since any menu link
+  // change could affect the admin menu (which essentially is an aggregate) and
+  // since there is no other way to get notified about stale caches. The cache
+  // only needs to be flushed once though, so we prevent a ton of needless
+  // subsequent calls with this static.
+  // @see http://drupal.org/node/918538
+  $was_flushed = &drupal_static(__FUNCTION__, array());
+  // $uid can be NULL. PHP automatically converts that into '' (empty string),
+  // which is different to uid 0 (zero).
+  if (isset($was_flushed[$uid])) {
+    return;
+  }
+  $was_flushed[$uid] = TRUE;
+
   $cid = 'admin_menu:';
   if (isset($uid)) {
     $cid .= $uid . ':';
