Add more detail to memory leak traces
This commit is contained in:
		
							parent
							
								
									d63cfc23d6
								
							
						
					
					
						commit
						2ec39484dc
					
				| @ -9,12 +9,6 @@ const std = @import("std"); | |||||||
| /// | /// | ||||||
| const stack_trace_frame_size = if (std.debug.sys_can_stack_trace) 16 else 0; | const stack_trace_frame_size = if (std.debug.sys_can_stack_trace) 16 else 0; | ||||||
| 
 | 
 | ||||||
| /// |  | ||||||
| /// |  | ||||||
| /// |  | ||||||
| const Context = struct { |  | ||||||
| 	allocation_info_head: ?*AllocationInfo = null, |  | ||||||
| 
 |  | ||||||
| /// | /// | ||||||
| /// | /// | ||||||
| /// | /// | ||||||
| @ -25,6 +19,12 @@ const Context = struct { | |||||||
| 	size: usize, | 	size: usize, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | /// | ||||||
|  | /// | ||||||
|  | /// | ||||||
|  | const Context = struct { | ||||||
|  | 	allocation_info_head: ?*AllocationInfo = null, | ||||||
|  | 
 | ||||||
| 	/// | 	/// | ||||||
| 	/// | 	/// | ||||||
| 	/// | 	/// | ||||||
| @ -167,7 +167,10 @@ pub fn trace_allocations() void { | |||||||
| 	var current_allocation_info = context.allocation_info_head; | 	var current_allocation_info = context.allocation_info_head; | ||||||
| 
 | 
 | ||||||
| 	while (current_allocation_info) |allocation_info| : (current_allocation_info = allocation_info.next_info) { | 	while (current_allocation_info) |allocation_info| : (current_allocation_info = allocation_info.next_info) { | ||||||
| 		std.debug.print("{d} byte leak detected", .{allocation_info.size}); | 		std.debug.print("{d} byte leak at 0x{x} detected: {}", .{ | ||||||
| 		std.debug.dumpStackTrace(allocation_info.stack_trace); | 			allocation_info.size, | ||||||
|  | 			@ptrToInt(allocation_info) + @sizeOf(AllocationInfo), | ||||||
|  | 			allocation_info.stack_trace | ||||||
|  | 		}); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user