1. Atlassian
  2. Project: Atlassian
  3. atlassian-profiling

Commits

Charles O'Farrell  committed 35519c3 Merge

Merged in atlassian/atlassian-profiling/cofarrell-disable-bug (pull request #1)

  • Participants
  • Parent commits cc989e8, 1659260
  • Branches master

Comments (0)

Files changed (2)

File src/main/java/com/atlassian/util/profiling/ProfilingTimerBean.java

View file
 
     public void setEndMem()
     {
-        this.totalMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) - startMem;
+        // Only capture total memory if we captured the startMem
+        if (hasMem)
+        {
+            this.totalMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) - startMem;
+        }
     }
 
     public String getResource()

File src/main/java/com/atlassian/util/profiling/UtilTimerStack.java

View file
 
     public static void pop(String name)
     {
-        if (!isActive())
-            return;
+        // We no longer check for isActive, as we want to cleanup the current stack of profiling beans
 
         ProfilingTimerBean currentTimer = (ProfilingTimerBean) current.get();
+        if (currentTimer == null)
+        {
+            return;
+        }
 
-        if (isProfileMemory())
-            currentTimer.setEndMem();
+        currentTimer.setEndMem();
         
         //if the timers are matched up with each other (ie push("a"); pop("a"));
-        if (currentTimer != null && name != null && name.equals(currentTimer.getResource()))
+        if (name != null && name.equals(currentTimer.getResource()))
         {
             currentTimer.setEndTime();
             ProfilingTimerBean parent = currentTimer.getParent();
         else
         {
             //if timers are not matched up, then print what we have, and then print warning.
-            if (currentTimer != null)
-            {
-                printTimes(currentTimer);
-                current.set(null); //prevent printing multiple times
-                log.debug("Unmatched Timer.  Was expecting {}, instead got {}", currentTimer.getResource(), name);
-            }
+            printTimes(currentTimer);
+            current.set(null); //prevent printing multiple times
+            log.debug("Unmatched Timer.  Was expecting {}, instead got {}", currentTimer.getResource(), name);
         }