mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Implement Capture Memory Snapshot action in Performance Plugin
Make the original action from YourKit to capture memory snapshots only using YourKit format GitOrigin-RevId: 59b1411eb6effb41109f8d054f18154909925a7e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4aef53977a
commit
996fd131d0
@@ -24,6 +24,7 @@
|
||||
</group>
|
||||
<group id="DiagnosticGroup">
|
||||
<separator/>
|
||||
<action id="CaptureMemorySnapShot" class="com.jetbrains.performancePlugin.actions.CaptureMemorySnapshotAction" icon="AllIcons.Actions.ProfileMemory"/>
|
||||
<action class="com.jetbrains.performancePlugin.actions.ExecuteScriptAction" id="performancePlugin.ExecuteScriptAction"/>
|
||||
<separator/>
|
||||
<add-to-group group-id="HelpDiagnosticTools" anchor="last"/>
|
||||
|
||||
@@ -74,6 +74,9 @@ dumping.project.files=Dumping Project Files\u2026
|
||||
comparing.project.files=Comparing Project Files\u2026
|
||||
comparing.project.files.for.0=Comparing Project Files for {0}\u2026
|
||||
|
||||
action.CaptureMemorySnapShot.text=Capture Memory Snapshot
|
||||
action.CaptureMemorySnapShot.description=Capture memory snapshot
|
||||
|
||||
intention.add.stopcommand=Add `%stopProfile` command
|
||||
inspection.message.activity.started.but.never.closed.with.stopprofile=`{0}` activity started, but never closed with `%stopProfile`
|
||||
inspection.message.two.startprofile.commands.cant.follow.each.other=`%startProfile` commands can''t follow each other. Add `%stopProfile` before `{0}`
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.jetbrains.performancePlugin.actions
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.progress.runModalTask
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.util.MemoryDumpHelper
|
||||
import com.intellij.util.SystemProperties
|
||||
import com.jetbrains.performancePlugin.PerformanceTestingBundle
|
||||
import com.jetbrains.performancePlugin.profilers.Profiler
|
||||
import com.jetbrains.performancePlugin.profilers.ProfilerHandlerUtils
|
||||
import java.io.File
|
||||
|
||||
class CaptureMemorySnapshotAction : DumbAwareAction() {
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val snapshotFolder = System.getProperty("snapshots.path", SystemProperties.getUserHome())
|
||||
val snapshotName = Profiler.formatSnapshotName(true) + ".hprof"
|
||||
val snapshotFile = File(snapshotFolder, snapshotName)
|
||||
try {
|
||||
MemoryDumpHelper.captureMemoryDump(snapshotFile.absolutePath)
|
||||
ProfilerHandlerUtils.notify(e.project, snapshotFile)
|
||||
}
|
||||
catch (exception: Exception) {
|
||||
ProfilerHandlerUtils.notifyCapturingError(exception, e.project)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getActionUpdateThread(): ActionUpdateThread {
|
||||
return ActionUpdateThread.BGT
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.isEnabledAndVisible = MemoryDumpHelper.memoryDumpAvailable()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user