mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 15:08:56 +08:00
694b5f108b
These (21 + 3 from previous PRs) are soon to be enabled in rubocop-discourse: Capybara/VisibilityMatcher Lint/DeprecatedOpenSSLConstant Lint/DisjunctiveAssignmentInConstructor Lint/EmptyConditionalBody Lint/EmptyEnsure Lint/LiteralInInterpolation Lint/NonLocalExitFromIterator Lint/ParenthesesAsGroupedExpression Lint/RedundantCopDisableDirective Lint/RedundantRequireStatement Lint/RedundantSafeNavigation Lint/RedundantStringCoercion Lint/RedundantWithIndex Lint/RedundantWithObject Lint/SafeNavigationChain Lint/SafeNavigationConsistency Lint/SelfAssignment Lint/UnreachableCode Lint/UselessMethodDefinition Lint/Void Previous PRs: Lint/ShadowedArgument Lint/DuplicateMethods Lint/BooleanSymbol RSpec/SpecFilePathSuffix
41 lines
972 B
Ruby
41 lines
972 B
Ruby
# frozen_string_literal: true
|
|
|
|
# to be used to compare ruby heaps generated in 2.1
|
|
# can isolate memory leaks
|
|
#
|
|
# rbtrace -p 15193 -e 'Thread.new{require "objspace"; ObjectSpace.trace_object_allocations_start; GC.start(full_mark: true); ObjectSpace.dump_all(output: File.open("heap.json","w"))}.join'
|
|
#
|
|
#
|
|
require "json"
|
|
|
|
if ARGV.length != 2
|
|
puts "Usage: diff_heaps [ORIG.json] [AFTER.json]"
|
|
exit 1
|
|
end
|
|
|
|
origs = Set.new
|
|
|
|
File
|
|
.open(ARGV[0], "r")
|
|
.each_line do |line|
|
|
parsed = JSON.parse(line)
|
|
origs << parsed["address"] if parsed && parsed["address"]
|
|
end
|
|
|
|
diff = []
|
|
|
|
File
|
|
.open(ARGV[1], "r")
|
|
.each_line do |line|
|
|
parsed = JSON.parse(line)
|
|
if parsed && parsed["address"]
|
|
diff << parsed unless origs.include? parsed["address"]
|
|
end
|
|
end
|
|
|
|
diff
|
|
.group_by { |x| [x["type"], x["file"], x["line"]] }
|
|
.map { |x, y| [x, y.count] }
|
|
.sort { |a, b| b[1] <=> a[1] }
|
|
.each { |x, y| puts "Leaked #{y} #{x[0]} objects at: #{x[1]}:#{x[2]}" }
|