Skip to content

Instantly share code, notes, and snippets.

View Criteo-dotnet-blog's full-sized avatar

Criteo-dotnet-blog

View GitHub Profile
java.lang.OutOfMemoryError: Java heap space
if (frame.Method.Type.Name == "System.Threading.Tasks.Task")
{
    if (frame.Method.Name == "Execute")
    {
        // the previous frame should contain the name of the method called by the task
        if (lastFrame != null)
        {
            // this is a task executing the method
            // given by lastFrame.DisplayString
        }
foreach (var thread in _host.Session.Clr.Threads
    .Where(t => t.IsThreadpoolWorker)
    .OrderBy(t => (t.LockCount > 0) ? -1 : (!t.IsAlive ? t.ManagedThreadId + 10000 : t.ManagedThreadId)))
private ThreadPoolItem GetQueueUserWorkItemCallback(dynamic element)
{
    ThreadPoolItem tpi = new ThreadPoolItem()
    {
        Address = (ulong)element,
        Type = ThreadRoot.WorkItem
    };
    // look for the callback given to ThreadPool.QueueUserWorkItem()
    var callback = element.callback;
// anonymous method
if (method.Type.Name == targetType.Name)
        {
            return $"{targetType.Name}.{method.Name}";
        }
        else
        // method is implemented by an class inherited from targetType
        // ... or a simple delegate indirection to a static/instance method
        {
            if (
if (method == null)
        {
            // could happen in case of static method
            methodPtr = action._methodPtrAux;
            method = _clr.GetMethodByAddress((ulong)methodPtr);
        }
internal string BuildDelegateMethodName(ClrType targetType, dynamic action)
{
    var methodPtr = action._methodPtr;
    if (methodPtr != null)
    {
        ClrMethod method = _clr.GetMethodByAddress((ulong)methodPtr);
private ThreadPoolItem GetTask(dynamic task)
{
    ThreadPoolItem tpi = new ThreadPoolItem()
    {
        Address = (ulong)task,
        Type = ThreadRoot.Task
    };
 
    // look for the context in m_action._target
private ThreadPoolItem GetThreadPoolItem(dynamic item)
{
    // get the ClrType directly from the dynamic proxy
    ClrType itemType = item.GetClrType();
    if (itemType.Name == "System.Threading.Tasks.Task")
    {
        return GetTask(item);
    }
    else if (itemType.Name == "System.Threading.QueueUserWorkItemCallback")
private IEnumerable<ThreadPoolItem> EnumerateThreadPoolStealingQueue(dynamic stealingQueue)
{
    var array = stealingQueue.m_array;
    if (array == null)
        yield break;
    foreach (var item in array)
    {
        if (item == null)
            continue;