diff --git a/lib/jsonapi/resource_serializer.rb b/lib/jsonapi/resource_serializer.rb
index <HASH>..<HASH> 100644
--- a/lib/jsonapi/resource_serializer.rb
+++ b/lib/jsonapi/resource_serializer.rb
@@ -230,7 +230,7 @@ module JSONAPI
     end
 
     def custom_generation_options
-      {
+      @_custom_generation_options ||= {
         serializer: self,
         serialization_options: @serialization_options
       }
Cache custom_generation_options options

This hash only needs to be computed once, and repeatedly building it
results in a lot of memory allocations.