summaryrefslogtreecommitdiff
path: root/libs/hwui/JankTracker.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2017-11-13 11:32:39 -0800
committerJohn Reck <jreck@google.com>2017-11-13 11:32:39 -0800
commit47f5c3a234c5c201ef640489af3ff25b5eec6652 (patch)
tree95308e88c2e4c19dd16030a4afe07603112ed8bc /libs/hwui/JankTracker.cpp
parentae5eb83a32a2005bd2c872bdf7b0621190ddb062 (diff)
Fix leak of FILE* in dumping
Avoid fdopen as fclose, which frees the FILE*, will close the FD which we don't want. Just normalize on dprintf instead, and we can add buffering if it turns out to matter at some point Test: ran 'dumpsys gfxinfo framestats' in a loop while observing PSS Change-Id: I7808753641aa1055cfdf570c3e017017f11f1dee
Diffstat (limited to 'libs/hwui/JankTracker.cpp')
-rw-r--r--libs/hwui/JankTracker.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp
index 5b676931a620..afdd339ba0a2 100644
--- a/libs/hwui/JankTracker.cpp
+++ b/libs/hwui/JankTracker.cpp
@@ -174,24 +174,22 @@ void JankTracker::dumpData(int fd, const ProfileDataDescription* description,
}
void JankTracker::dumpFrames(int fd) {
- FILE* file = fdopen(fd, "a");
- fprintf(file, "\n\n---PROFILEDATA---\n");
+ dprintf(fd, "\n\n---PROFILEDATA---\n");
for (size_t i = 0; i < static_cast<size_t>(FrameInfoIndex::NumIndexes); i++) {
- fprintf(file, "%s", FrameInfoNames[i].c_str());
- fprintf(file, ",");
+ dprintf(fd, "%s", FrameInfoNames[i].c_str());
+ dprintf(fd, ",");
}
for (size_t i = 0; i < mFrames.size(); i++) {
FrameInfo& frame = mFrames[i];
if (frame[FrameInfoIndex::SyncStart] == 0) {
continue;
}
- fprintf(file, "\n");
+ dprintf(fd, "\n");
for (int i = 0; i < static_cast<int>(FrameInfoIndex::NumIndexes); i++) {
- fprintf(file, "%" PRId64 ",", frame[i]);
+ dprintf(fd, "%" PRId64 ",", frame[i]);
}
}
- fprintf(file, "\n---PROFILEDATA---\n\n");
- fflush(file);
+ dprintf(fd, "\n---PROFILEDATA---\n\n");
}
void JankTracker::reset() {