code: public static void recordAllocation(int count, String desc, Object newObj) {
      if (Objects.equals(recordingAllocation.get(), Boolean.TRUE)) {
        return;
      }
  
      recordingAllocation.set(Boolean.TRUE);
  
      if (count >= 0) {
        desc = desc.replace('.', '/');
      }
  
      // Copy value into local variable to prevent NPE that occurs when
      // instrumentation field is set to null by this class's shutdown hook
      // after another thread passed the null check but has yet to call
      // instrumentation.getObjectSize()
      // See https://github.com/google/allocation-instrumenter/issues/15
      Instrumentation instr = instrumentation;
      if (instr != null) {
        // calling getObjectSize() could be expensive,
        // so make sure we do it only once per object
        long objectSize = -1;
  
        Sampler[] samplers = additionalSamplers;
        if (samplers != null) {
          if (objectSize < 0) {
            objectSize = getObjectSize(newObj, (count >= 0), instr);
          }
          for (Sampler sampler : samplers) {
            sampler.sampleAllocation(count, desc, newObj, objectSize);
          }
        }
      }
  
      recordingAllocation.set(Boolean.FALSE);
    }
docs: Records the allocation. This method is invoked on every allocation performed by the system.
  
  @param count the count of how many instances are being allocated, if an array is being
  allocated. If an array is not being allocated, then this value will be -1.
  @param desc the descriptor of the class/primitive type being allocated.
  @param newObj the new <code>Object</code> whose allocation is being recorded.