Subject: bug#79023: 30.1.90; Suspicion of memory leak on internal_redisplay (MacOS)

From: Przemysław Alexander Kamiński<[email-masked]>
Date: Wed, 16 Jul 2025 18:45:47 +0200

Update to the topic:

- I've setup up debug pipeline and was able to make a proper clean build 
and ensured GC plenty had plenty time to grab (snapshots every 30s)
- Only minor leaks are remaining
- I started looking at the allocations: on clean instance moving 
mouse/resizing window was expensive (see excerpt)
- Instance with uptime of 1 hour it has footprint of 405MiB (mind the 
debugging symbols though)

Best,
Przemysław Alexander Kamiński

---

20.06 MB      99.0%	6421	 	start
20.06 MB      99.0%	6421	 	 main
20.06 MB      99.0%	6421	 	  Frecursive_edit
20.06 MB      99.0%	6421	 	   recursive_edit_1
20.06 MB      99.0%	6421	 	    command_loop
20.06 MB      99.0%	6421	 	     command_loop.cold.1
20.06 MB      99.0%	6421	 	      internal_catch
20.06 MB      99.0%	6421	 	       command_loop_2
20.06 MB      99.0%	6421	 	        internal_condition_case
20.06 MB      99.0%	6421	 	         command_loop_1
20.04 MB      98.9%	6274	 	          read_key_sequence
20.04 MB      98.9%	6273	 	           read_char
19.24 MB      94.9%	588	 	            read_decoded_event_from_main_queue
19.24 MB      94.9%	588	 	             read_event_from_main_queue
19.24 MB      94.9%	587	 	              kbd_buffer_get_event
19.24 MB      94.9%	587	 	               wait_reading_process_output
11.11 MB      54.8%	584	 	                ns_select_1
11.11 MB      54.8%	584	 	                 -[EmacsApp run]
11.11 MB      54.8%	584	 	                  -[NSApplication run]
11.09 MB      54.7%	558	 	                   -[NSApplication 
_handleEvent:]
11.09 MB      54.7%	558	 	                    -[EmacsApp sendEvent:]
11.09 MB      54.7%	558	 	                     
-[NSApplication(NSEventRouting) sendEvent:]
11.09 MB      54.7%	558	 	                      
-[NSWindow(NSEventRouting) sendEvent:]
11.09 MB      54.7%	558	 	                       
-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:]
11.09 MB      54.7%	558	 	                        
-[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:]
11.09 MB      54.7%	558	 	                         -[NSThemeFrame 
mouseDown:]
11.09 MB      54.7%	558	 	                          -[NSThemeFrame 
handleMouseDown:]
11.09 MB      54.7%	558	 	                           -[NSTitledFrame 
attemptResizeWithEvent:]
11.09 MB      54.7%	558	 	                            
-[NSWindow(NSWindowResizing) _resizeWithEvent:]
11.07 MB      54.6%	416	 	                             
-[NSApplication(NSEventRouting) 
_nextEventMatchingEventMask:untilDate:inMode:dequeue:]
7.66 KB       0.0%	88	 	                             
-[NSWindow(NSWindowResizing) 
_frame:resizedFromEdge:withDelta:withEvent:withState:]
7.34 KB       0.0%	29	 	                             -[EmacsWindow 
setFrame:display:]
3.27 KB       0.0%	21	 	                             -[NSWindow 
_endLiveResize]
384 Bytes    0.0%	2	 	                             -[NSAutoreleasePool 
drain]
96 Bytes    0.0%	1	 	                             
-[NSWindow(NSScreenLayout) _saveWindowLayoutForScreenLayout]
64 Bytes    0.0%	1	 	                             _objc_msgSend_uncached
19.36 KB       0.0%	26	 	                   
-[NSApplication(NSEventRouting) 
_nextEventMatchingEventMask:untilDate:inMode:dequeue:]
8.13 MB      40.0%	3	 	                detect_input_pending_run_timers
8.13 MB      40.0%	3	 	                 flush_frame
8.13 MB      40.0%	3	 	                  ns_flush_display
8.13 MB      40.0%	3	 	                   ns_read_socket_1
8.13 MB      40.0%	3	 	                    -[EmacsApp run]
8.13 MB      40.0%	3	 	                     -[NSApplication run]
8.13 MB      40.0%	3	 	                      -[NSApplication 
_handleEvent:]
8.13 MB      40.0%	3	 	                       -[EmacsApp sendEvent:]
8.13 MB      40.0%	3	 	                        
-[NSApplication(NSEventRouting) sendEvent:]
8.13 MB      40.0%	3	 	                         routeMouseMovedEvent
8.13 MB      40.0%	3	 	                          
-[NSWindow(NSEventRouting) sendEvent:]
8.13 MB      40.0%	3	 	                           
-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:]
8.13 MB      40.0%	3	 	                            _routeMouseMovedEvent
8.13 MB      40.0%	3	 	                             -[EmacsView 
mouseMoved:]
8.13 MB      40.0%	3	 	                              
ns_note_mouse_movement
8.13 MB      40.0%	3	 	                               -[EmacsView 
lockFocus]
8.13 MB      40.0%	3	 	                                -[EmacsLayer 
getContext]
8.13 MB      40.0%	3	 	                                 IOSurfaceCreate
8.13 MB      40.0%	2	 	                                  -[IOSurface 
initWithProperties:]
8.13 MB      40.0%	2	 	                                   
IOSurfaceClientCreateChild
400 Bytes    0.0%	1	 	                                    
_ioSurfaceClientCreateWithLockResult
400 Bytes    0.0%	1	 	                                     
_malloc_type_malloc_outlined
16 Bytes    0.0%	1	 	                                  
_objc_rootAllocWithZone
16 Bytes    0.0%	1	 	                                   
_malloc_type_calloc_outlined