memory_profiler 0.9.11 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7da6190dc6c838833e47d41765b0cfff971a88fd650968126345a022b7adab9f
4
- data.tar.gz: 99c847bf242406d438b06a9a4c747bf7200556f7380e4c93fa69476e523d0675
3
+ metadata.gz: 144e3c662a07ad7303cd60990d43aef9c050028689fbfef285e8eadd8a161b78
4
+ data.tar.gz: c24f4ed76fc71ee0fb17b9edf5f2d46b621aeb443a2006cd34c2eddad7ddb101
5
5
  SHA512:
6
- metadata.gz: 821c0b5746630a740e23570b31bc1faab53b2be90d1f53000310ca2fab122b8e254f93ae25fffa63ca95b7c350b721d62320276dada82c05712945047446a683
7
- data.tar.gz: a354ea734d19c16510c6c76612d58ea6d830f39883ef215accbc9f3c33a3f745b55a90275cdef8779b03d1dc4779fe156a9e0bfb1aa1f1073cd03f4b54696e4f
6
+ metadata.gz: f5a9469d8ef19bace4028033dbee40b62aad465933eb8f393f1f1e3ea72f0ac88a390b20412e4f3edbae333c12a1ab75d8b63669d5fddf09fe79cab7c5261f16
7
+ data.tar.gz: dbad24a4cad1d5ef4adaac6ed89cd79695cd23d2fde7eb0e45d8bcb3b3193da5fefd24a10aa8f9653fa74f94d33602379b023b94dd97d544ecfaea5b799d5fc1
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.12
4
+ - Correct bug under-reporting memory for large string allocation @sam
5
+
3
6
  ## 0.9.11
4
7
  - Reduce memory needed for string allocation tracing @dgynn
5
8
  - Use yield rather than block.call to reduce an allocation @dgynn
@@ -35,7 +35,7 @@ module MemoryProfiler
35
35
  # This string is shortened to 200 characters which is what the string report shows
36
36
  # The string report can still list unique strings longer than 200 characters
37
37
  # separately because the object_id of the shortened string will be different
38
- @string_cache[obj] ||= obj[0,200]
38
+ @string_cache[obj] ||= String.new << obj[0,200]
39
39
  end
40
40
  end
41
41
  end
@@ -32,6 +32,8 @@ module MemoryProfiler
32
32
  end
33
33
 
34
34
  def start
35
+ GC.start
36
+ GC.start
35
37
  GC.start
36
38
  GC.disable
37
39
 
@@ -46,6 +48,8 @@ module MemoryProfiler
46
48
 
47
49
  GC.enable
48
50
  GC.start
51
+ GC.start
52
+ GC.start
49
53
 
50
54
  # Caution: Do not allocate any new Objects between the call to GC.start and the completion of the retained
51
55
  # lookups. It is likely that a new Object would reuse an object_id from a GC'd object.
@@ -107,9 +111,11 @@ module MemoryProfiler
107
111
  class_name = helper.lookup_class_name(klass)
108
112
  gem = helper.guess_gem(file)
109
113
 
114
+ # we do memsize first to avoid freezing as a side effect and shifting
115
+ # storage to the new frozen string, this happens on @hash[s] in lookup_string
116
+ memsize = ObjectSpace.memsize_of(obj) + rvalue_size_adjustment
110
117
  string = klass == String ? helper.lookup_string(obj) : nil
111
118
 
112
- memsize = ObjectSpace.memsize_of(obj) + rvalue_size_adjustment
113
119
  # compensate for API bug
114
120
  memsize = rvalue_size if memsize > 100_000_000_000
115
121
  result[obj.__id__] = MemoryProfiler::Stat.new(class_name, gem, file, location, memsize, string)
@@ -1,3 +1,3 @@
1
1
  module MemoryProfiler
2
- VERSION = "0.9.11"
2
+ VERSION = "0.9.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memory_profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-22 00:00:00.000000000 Z
11
+ date: 2018-10-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Memory profiling routines for Ruby 2.1+
14
14
  email: