Exemplo n.º 1
0
        private static void init()
        {
            MemStats memStats = default;

            if (sizeof_C_MStats != @unsafe.Sizeof(memStats))
            {
                println(sizeof_C_MStats, @unsafe.Sizeof(memStats));
                throw("MStats vs MemStatsType size mismatch");
            }

            if (@unsafe.Offsetof(memstats.heap_live) % 8L != 0L)
            {
                println(@unsafe.Offsetof(memstats.heap_live));
                throw("memstats.heap_live not aligned to 8 bytes");
            }
        }
Exemplo n.º 2
0
    public void Draw(Rect r)
    {
        int   border        = MemConst.TableBorder;
        float split         = MemConst.SplitterRatio;
        int   toolbarHeight = 50;

        GUILayout.BeginArea(r, MemStyles.Background);
        GUILayout.BeginHorizontal(MemStyles.Toolbar);
        // categories
        {
            GUILayout.Label("Category: ", GUILayout.MinWidth(120));

            string[] literals = _unpacked != null ? _categoryLiterals : MemConst.MemTypeCategories;

            int newCategory = GUILayout.SelectionGrid(_memTypeCategory, literals, literals.Length, MemStyles.ToolbarButton);
            if (newCategory != _memTypeCategory)
            {
                _memTypeCategory = newCategory;
                RefreshTables();
            }
        }
        GUILayout.FlexibleSpace();

        // size limiter
        {
            GUILayout.Label("Size: ", GUILayout.MinWidth(120));
            int newLimiter = GUILayout.SelectionGrid(_memTypeSizeLimiter, MemConst.MemTypeLimitations, MemConst.MemTypeLimitations.Length, MemStyles.ToolbarButton);
            if (newLimiter != _memTypeSizeLimiter)
            {
                _memTypeSizeLimiter = newLimiter;
                RefreshTables();
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(3);

        GUILayout.BeginHorizontal(MemStyles.Toolbar);

        // search box - types
        {
            string enteredString = GUILayout.TextField(_searchTypeString, 100, MemStyles.SearchTextField, GUILayout.MinWidth(200));
            if (enteredString != _searchTypeString)
            {
                _searchTypeString = enteredString;
                RefreshTables();
            }
            if (GUILayout.Button("", MemStyles.SearchCancelButton))
            {
                _searchTypeString = "";
                GUI.FocusControl(null); // Remove focus if cleared
                RefreshTables();
            }
        }

        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Show Type Stats", EditorStyles.toolbarButton))
        {
            MemStats.ShowTypeStats(_typeTable.GetSelected() as MemType);
        }
        GUILayout.FlexibleSpace();

        // search box - instances
        {
            string enteredString = GUILayout.TextField(_searchInstanceString, 100, MemStyles.SearchTextField, GUILayout.MinWidth(200));
            if (enteredString != _searchInstanceString)
            {
                _searchInstanceString = enteredString;
                RefreshTables();
            }
            if (GUILayout.Button("", MemStyles.SearchCancelButton))
            {
                _types.Remove(MemConst.SearchResultTypeString);
                _searchInstanceString = "";
                GUI.FocusControl(null); // Remove focus if cleared
                RefreshTables();
            }
        }

        GUILayout.EndHorizontal();

        int startY = toolbarHeight + border;
        int height = (int)(r.height - border * 2 - toolbarHeight);

        if (_typeTable != null)
        {
            _typeTable.Draw(new Rect(border, startY, (int)(r.width * split - border * 1.5f), height));
        }
        if (_objectTable != null)
        {
            _objectTable.Draw(new Rect((int)(r.width * split + border * 0.5f), startY, (int)r.width * (1.0f - split) - border * 1.5f, height));
        }
        GUILayout.EndArea();
    }