Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modis Memory Leak #14

Closed
armahmoudi opened this issue Jul 9, 2018 · 3 comments
Closed

Modis Memory Leak #14

armahmoudi opened this issue Jul 9, 2018 · 3 comments

Comments

@armahmoudi
Copy link

Looking into memory leak issues with Rpush, which uses Modis for Redis storage, it seems like Modis has a memory leak issue. The memory heap dump below indicates the top two memory allocations are from Modis: (multiple heap dumps were done after GC.start which enforces a garbage cleaning, and the memory used by these lines has increased over time)

Analyzing Heap (Generation: all)
-------------------------------

allocated by memory (22439036) (in bytes)
==============================
  14173604  /vendor/bundle/ruby/2.4.0/gems/msgpack-1.2.4/lib/msgpack.rb:34
   3439904  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:102
   1050874  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/interruptible_sleep.rb:5
   1050544  eval:1
    324474  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:394
    286240  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/numeric/conversions.rb:139
    272648  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/finder.rb:72
    257500  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/client/active_model/apns/notification.rb:27
    195080  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:94
    193324  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/json/encoding.rb:87
    128040  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:95
    106400  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:14
    105072  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:32
     95400  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:28
     79680  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:18
     75632  /vendor/bundle/ruby/2.4.0/gems/statsd-ruby-1.4.0/lib/statsd.rb:488
     63744  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/app_runner.rb:123
     63680  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:11
     61632  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/store/redis.rb:31
     53658  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:31
     47424  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:172
     42248  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/array/grouping.rb:39
     40128  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/time/calculations.rb:230
     37008  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:13
     32280  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/hash_with_indifferent_access.rb:97
     28080  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:12
     26560  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/dispatcher/apns_http2.rb:25
     21408  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:232
      8928  /lib/ruby/2.4.0/openssl/buffering.rb:325
      7561  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274
      5320  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:180
      5184  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/connection.rb:667
      2400  /lib/ruby/2.4.0/net/http/header.rb:82
      2226  /lib/ruby/2.4.0/net/http/response.rb:62
      1760  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:7
      1452  /lib/ruby/2.4.0/logger.rb:695
      1440  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:57
      1440  /vendor/bundle/ruby/2.4.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb:8
      1440  /lib/ruby/2.4.0/net/http/header.rb:14
      1413  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/module/delegation.rb:214
      1378  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:157
      1250  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:45
      1226  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:3
      1200  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:30
      1154  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:37
      1128  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/column.rb:55
      1128  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:242
      1106  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:133
      1106  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:107
      1080  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:35

object count (106492)
==============================
  59801  /vendor/bundle/ruby/2.4.0/gems/msgpack-1.2.4/lib/msgpack.rb:34
   7156  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/numeric/conversions.rb:139
   4877  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:102
   4877  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:94
   4877  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/finder.rb:72
   2663  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:394
   2574  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/json/encoding.rb:87
   2453  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/client/active_model/apns/notification.rb:27
   2385  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:32
   2385  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:95
   2385  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:28
   1328  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:18
    807  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/hash_with_indifferent_access.rb:97
    665  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:14
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/dispatcher/apns_http2.rb:25
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/app_runner.rb:123
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:11
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:12
    664  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:13
    664  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/array/grouping.rb:39
    642  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/store/redis.rb:31
    418  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/time/calculations.rb:230
    326  /vendor/bundle/ruby/2.4.0/gems/statsd-ruby-1.4.0/lib/statsd.rb:488
    306  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:31
    247  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:172
    223  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:232
    133  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:180
    123  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274
     60  /lib/ruby/2.4.0/net/http/header.rb:82
     54  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/connection.rb:667
     42  /lib/ruby/2.4.0/net/http/response.rb:62
     36  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:57
     27  /lib/ruby/2.4.0/openssl/buffering.rb:325
     21  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/interruptible_sleep.rb:5
     20  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:30
     18  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:35
     17  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/schema_cache.rb:90
     15  eval:1
     14  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:439
     14  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/module/delegation.rb:214
     11  /vendor/bundle/ruby/2.4.0/gems/arel-6.0.4/lib/arel/visitors/visitor.rb:16
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:732
     10  /vendor/bundle/ruby/2.4.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb:16
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:242
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/column.rb:55
      9  /lib/ruby/2.4.0/net/http/response.rb:43
      9  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:72
      9  /lib/ruby/2.4.0/openssl/buffering.rb:182
      8  /vendor/bundle/ruby/2.4.0/gems/tesla_logging-0.1.31/lib/tesla_logging/logger_base.rb:87
      8  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:47

High Ref Counts
==============================

  127357  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:102
  81659  /vendor/bundle/ruby/2.4.0/gems/msgpack-1.2.4/lib/msgpack.rb:34
   7548  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/finder.rb:72
   4877  /vendor/bundle/ruby/2.4.0/gems/modis-2.1.0/lib/modis/attribute.rb:94
   3329  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:18
   3320  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/app_runner.rb:123
   2788  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274
   2453  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/array/grouping.rb:39
   2205  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:11
   2045  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:95
   1992  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/dispatcher/apns_http2.rb:25
   1029  /vendor/bundle/ruby/2.4.0/gems/activemodel-4.2.10/lib/active_model/dirty.rb:172
    514  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:13
    297  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/apns2/delivery.rb:31
    278  /lib/ruby/2.4.0/openssl/buffering.rb:325
    266  /vendor/bundle/ruby/2.4.0/gems/http-2-0.9.0/lib/http/2/compressor.rb:180
     70  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:30
     68  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:7
     63  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/type/type_map.rb:35
     61  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/interruptible_sleep.rb:5
     60  /lib/ruby/2.4.0/net/http/header.rb:14
     56  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_adapter.rb:439
     45  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:242
     45  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/column.rb:55
     40  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:732
     32  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/core_ext/module/delegation.rb:214
     30  /lib/ruby/2.4.0/net/http/header.rb:82
     26  eval:1
     24  /vendor/bundle/ruby/2.4.0/gems/thread_safe-0.3.6/lib/thread_safe/non_concurrent_cache_backend.rb:8
     23  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/attributes.rb:98
     23  /vendor/bundle/ruby/2.4.0/gems/net-http2-0.17.0/lib/net-http2/request.rb:32
     21  /lib/ruby/2.4.0/openssl/buffering.rb:182
     21  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:45
     20  /vendor/bundle/ruby/2.4.0/gems/arel-6.0.4/lib/arel/visitors/visitor.rb:15
     20  /vendor/bundle/ruby/2.4.0/gems/rpush-3.2.0/lib/rpush/daemon/batch.rb:12
     17  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/schema_cache.rb:13
     15  /lib/ruby/2.4.0/net/http.rb:940
     15  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/mysql2_adapter.rb:20
     15  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:3
     15  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:157
     15  /lib/ruby/2.4.0/net/http/response.rb:30
     13  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/attribute_decorators.rb:28
     12  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/core.rb:238
     12  /lib/ruby/2.4.0/net/http/response.rb:62
     11  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:37
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:171
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:472
     10  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/abstract/transaction.rb:107
     10  /vendor/bundle/ruby/2.4.0/gems/activesupport-4.2.10/lib/active_support/per_thread_registry.rb:50
      9  /vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.10/lib/active_record/scoping/named.rb:33
@armahmoudi
Copy link
Author

lib/modis/attribute.rb:102 also has the highest memory reference count of 127357 objects which doesn't seem right.

@aried3r
Copy link
Member

aried3r commented Aug 2, 2018

Hey! We talked over at rpush/rpush#439, do you think we can produce a minimal example using just Modis? Maybe then we can debug it more easily and make sure it's in Modis and not the way Rpush uses it.

@aried3r
Copy link
Member

aried3r commented Feb 11, 2019

This was supposedly fixed in rpush itself, please see rpush/rpush#439 (comment) and references PRs.

@aried3r aried3r closed this as completed Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants