diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index <HASH>..<HASH> 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -117,6 +117,12 @@ module ActiveRecord
     # Clears out the association cache.
     def clear_association_cache #:nodoc:
       self.class.reflect_on_all_associations.to_a.each do |assoc|
+        if IdentityMap.enabled? && instance_variable_defined?("@#{assoc.name}")
+          targets = [*instance_variable_get("@#{assoc.name}")]
+          targets.map! { |t| t.respond_to?(:target) ? t.target : t }
+          targets.compact!
+          targets.each { |r| IdentityMap.remove r }
+        end
         instance_variable_set "@#{assoc.name}", nil
       end if self.persisted?
     end
Remove associated objects from IM when clearing them from association cache.