Home | History | Annotate | Download | only in jni
      1 // Copyright 2017 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef LIBMEMTRACK_WRAPPER_H_
      6 #define LIBMEMTRACK_WRAPPER_H_
      7 
      8 #include <stdint.h>
      9 
     10 // Wrapper on top of libmemtrack API.
     11 
     12 // Opaque structure with memory stats.
     13 // See $ANDROID/system/core/libmemtrack/include/memtrack/memtrack.h for details.
     14 struct libmemtrack_proc;
     15 
     16 // These numbers are vendor-specific and can't be trusted as a stable metric
     17 // across different hardware or driver versions.
     18 class MemtrackProc {
     19  public:
     20   explicit MemtrackProc(int pid);
     21   ~MemtrackProc();
     22 
     23   uint64_t graphics_total() const;
     24   uint64_t graphics_pss() const;
     25   uint64_t gl_total() const;
     26   uint64_t gl_pss() const;
     27   uint64_t other_total() const;
     28   uint64_t other_pss() const;
     29 
     30   bool has_errors() const { return proc_ == nullptr; };
     31 
     32  private:
     33   MemtrackProc(const MemtrackProc&) = delete;
     34   void operator=(const MemtrackProc&) = delete;
     35 
     36   libmemtrack_proc* proc_ = nullptr;
     37 };
     38 
     39 #endif  // LIBMEMTRACK_WRAPPER_H_
     40