Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ Any icon files(`*.ico`) in the build directory, directories specified with
_icondirs_ make variable and `win32` directory under the ruby
source directory will be included in DLL or executable files, according
to their base names.

$(RUBY_INSTALL_NAME).ico or ruby.ico --> $(RUBY_INSTALL_NAME).exe
$(RUBYW_INSTALL_NAME).ico or rubyw.ico --> $(RUBYW_INSTALL_NAME).exe
the others --> $(RUBY_SO_NAME).dll
Expand Down
5 changes: 2 additions & 3 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -6912,7 +6912,7 @@ static const rb_data_type_t env_data_type = {
* A \Hash object maps each of its unique keys to a specific value.
*
* A hash has certain similarities to an Array, but:

*
* - An array index is always an integer.
* - A hash key can be (almost) any object.
*
Expand Down Expand Up @@ -7313,7 +7313,7 @@ static const rb_data_type_t env_data_type = {
* - #keys: Returns an array containing all keys in +self+.
* - #rassoc: Returns a 2-element array consisting of the key and value
* of the first-found entry having a given value.
* - #values: Returns an array containing all values in +self+/
* - #values: Returns an array containing all values in +self+.
* - #values_at: Returns an array containing values for given keys.
*
* ==== Methods for Assigning
Expand Down Expand Up @@ -7362,7 +7362,6 @@ static const rb_data_type_t env_data_type = {
*
* ==== Methods for Transforming Keys and Values
*
* - #flatten!: Returns +self+, flattened.
* - #invert: Returns a hash with the each key-value pair inverted.
* - #transform_keys: Returns a copy of +self+ with modified keys.
* - #transform_keys!: Modifies keys in +self+
Expand Down
100 changes: 60 additions & 40 deletions tool/lib/memory_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,68 @@ def self.read_status
data.scan(pat) {|k, v| keys << k.downcase.intern}

when /mswin|mingw/ =~ RUBY_PLATFORM
require 'fiddle/import'
require 'fiddle/types'

module Win32
extend Fiddle::Importer
dlload "kernel32.dll", "psapi.dll"
include Fiddle::Win32Types
typealias "SIZE_T", "size_t"

PROCESS_MEMORY_COUNTERS = struct [
"DWORD cb",
"DWORD PageFaultCount",
"SIZE_T PeakWorkingSetSize",
"SIZE_T WorkingSetSize",
"SIZE_T QuotaPeakPagedPoolUsage",
"SIZE_T QuotaPagedPoolUsage",
"SIZE_T QuotaPeakNonPagedPoolUsage",
"SIZE_T QuotaNonPagedPoolUsage",
"SIZE_T PagefileUsage",
"SIZE_T PeakPagefileUsage",
]

typealias "PPROCESS_MEMORY_COUNTERS", "PROCESS_MEMORY_COUNTERS*"

extern "HANDLE GetCurrentProcess()", :stdcall
extern "BOOL GetProcessMemoryInfo(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD)", :stdcall

module_function
def memory_info
size = PROCESS_MEMORY_COUNTERS.size
data = PROCESS_MEMORY_COUNTERS.malloc
data.cb = size
data if GetProcessMemoryInfo(GetCurrentProcess(), data, size)
keys.push(:size, :rss, :peak)

begin
require 'fiddle/import'
require 'fiddle/types'
rescue LoadError
# Fallback to PowerShell command to get memory information for current process
def self.read_status
cmd = [
"powershell.exe", "-NoProfile", "-Command",
"Get-Process -Id #{$$} | " \
"% { Write-Output $_.PagedMemorySize64 $_.WorkingSet64 $_.PeakWorkingSet64 }"
]

IO.popen(cmd, "r", err: [:child, :out]) do |out|
if /^(\d+)\n(\d+)\n(\d+)$/ =~ out.read
yield :size, $1.to_i
yield :rss, $2.to_i
yield :peak, $3.to_i
end
end
end
else
module Win32
extend Fiddle::Importer
dlload "kernel32.dll", "psapi.dll"
include Fiddle::Win32Types
typealias "SIZE_T", "size_t"

PROCESS_MEMORY_COUNTERS = struct [
"DWORD cb",
"DWORD PageFaultCount",
"SIZE_T PeakWorkingSetSize",
"SIZE_T WorkingSetSize",
"SIZE_T QuotaPeakPagedPoolUsage",
"SIZE_T QuotaPagedPoolUsage",
"SIZE_T QuotaPeakNonPagedPoolUsage",
"SIZE_T QuotaNonPagedPoolUsage",
"SIZE_T PagefileUsage",
"SIZE_T PeakPagefileUsage",
]

typealias "PPROCESS_MEMORY_COUNTERS", "PROCESS_MEMORY_COUNTERS*"

extern "HANDLE GetCurrentProcess()", :stdcall
extern "BOOL GetProcessMemoryInfo(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD)", :stdcall

module_function
def memory_info
size = PROCESS_MEMORY_COUNTERS.size
data = PROCESS_MEMORY_COUNTERS.malloc
data.cb = size
data if GetProcessMemoryInfo(GetCurrentProcess(), data, size)
end
end
end

keys.push(:size, :rss, :peak)
def self.read_status
if info = Win32.memory_info
yield :size, info.PagefileUsage
yield :rss, info.WorkingSetSize
yield :peak, info.PeakWorkingSetSize
def self.read_status
if info = Win32.memory_info
yield :size, info.PagefileUsage
yield :rss, info.WorkingSetSize
yield :peak, info.PeakWorkingSetSize
end
end
end
when (require_relative 'find_executable'
Expand Down