Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
         
       
     
  
  
  
  
  
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
MallocDebug
  public
  
  
  
  class
  MallocDebug
  
    extends Object
  
  
  
  
  
      implements
      
        AutoCloseable
      
  
  
  
    
    | java.lang.Object
     | 
  
  
  
    
      |    ↳ | 
    
    com.android.sts.common.MallocDebug
     | 
  
  
  
    
  Utilities to setup malloc debug options on a process, check for malloc debug errors, and cleaning
 up afterwards.
Summary
Public methods | 
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      close()
      
      
     | 
  
  
  
  
  
    
        
        
        static
        
        
        AutoCloseable
     | 
  
    
      
      withLibcMallocDebugOnAllNewProcesses(ITestDevice device, String mallocDebugOptions)
      
      
        Start attaching libc malloc debug to all processes launching after this call, asserting no
 malloc debug error upon closing.
        
    
 
      
     | 
  
  
  
  
  
    
        
        
        static
        
        
        AutoCloseable
     | 
  
    
      
      withLibcMallocDebugOnNewProcess(ITestDevice device, String mallocDebugOptions, String processName)
      
      
        Set up so that malloc debug will attach to the given processName, and assert no malloc debug
 error upon closing.
        
    
 
      
     | 
  
  
  
  
  
    
        
        
        static
        
        
        AutoCloseable
     | 
  
    
      
      withLibcMallocDebugOnService(ITestDevice device, String mallocDebugOptions, String processName)
      
      
        Restart the given service and enable malloc debug on it, asserting no malloc debug error upon
 closing.
        
    
 
      
     | 
  
  
Public methods
    close
    
public void close ()
    
    
    
  
      
  
 
    withLibcMallocDebugOnAllNewProcesses
    
public static AutoCloseable withLibcMallocDebugOnAllNewProcesses (ITestDevice device, 
                String mallocDebugOptions)
    
    
    
  Start attaching libc malloc debug to all processes launching after this call, asserting no
 malloc debug error upon closing.
    
    | Parameters | 
      
        device | 
        
          ITestDevice: the device to use | 
      
      
        mallocDebugOptions | 
        
          String: value to set libc.debug.malloc.options to. | 
      
    
    
      | Returns | 
      
        AutoCloseable | 
        The AutoCloseable object that will disable libc malloc debug and check for malloc
     debug errors when closed.
 | 
      
    
      
  
 
    withLibcMallocDebugOnNewProcess
    
public static AutoCloseable withLibcMallocDebugOnNewProcess (ITestDevice device, 
                String mallocDebugOptions, 
                String processName)
    
    
    
  Set up so that malloc debug will attach to the given processName, and assert no malloc debug
 error upon closing. Note that processName will need to be manually launched after this call.
    
    | Parameters | 
      
        device | 
        
          ITestDevice: the device to use | 
      
      
        mallocDebugOptions | 
        
          String: value to set libc.debug.malloc.options to. | 
      
      
        processName | 
        
          String: the process to attach libc malloc debug to. Should not be running yet. | 
      
    
    
      | Returns | 
      
        AutoCloseable | 
        The AutoCloseable object that will disable libc malloc debug and check for malloc
     debug errors when closed.
 | 
      
    
      
  
 
    withLibcMallocDebugOnService
    
public static AutoCloseable withLibcMallocDebugOnService (ITestDevice device, 
                String mallocDebugOptions, 
                String processName)
    
    
    
  Restart the given service and enable malloc debug on it, asserting no malloc debug error upon
 closing.
    
    | Parameters | 
      
        device | 
        
          ITestDevice: the device to use | 
      
      
        mallocDebugOptions | 
        
          String: value to set libc.debug.malloc.options to. | 
      
      
        processName | 
        
          String: the service process to attach libc malloc debug to. Should be running. | 
      
    
    
      | Returns | 
      
        AutoCloseable | 
        The AutoCloseable object that will restart/unattach the service, disable libc malloc
     debug, and check for malloc debug errors when closed.
 | 
      
    
      
  
 
 
 
  
  
 
  
    
    
      
    
    
  
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2022-11-18 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-11-18 UTC."],[],[]]