How to clear lines form Debug.DrawLine?

I need to write a custom editor tools for my application. One of those tools should draw a 2d grid inside the scene. I use Debug.DrawLine to do it. The grid should also redraw if user changes the grid parameters in my tool. Yet, I can't seem to find the function to clear already drawn lines. How can I clear already drawn lines? I think it would be beneficial to provide a code. Note that Im' not redrawing it here every frame. It only draws on button stroke.

public void OnGUI()
{

...............................................................................

        if(GUILayout.Button("Map world", GuiLOpt)) { DrawGrid(); }

}

protected void DrawGrid()

{

        HandleUtility.Repaint();
        float XShift, ZShift;       

        XShift = cellSize * ((float)cellNumX) / 2;
        ZShift = cellSize * ((float)cellNumY) / 2; 

        for(int i = 0; i <= cellNumY; i++) 
            Debug.DrawLine(new Vector3(-XShift, 0, -ZShift + i * cellSize), new Vector3(XShift, 0, -ZShift + i * cellSize));

        for(int i = 0; i <= cellNumX; i++) 
            Debug.DrawLine(new Vector3(-XShift + i * cellSize, 0, -ZShift), new Vector3(-XShift + i * cellSize, 0, ZShift));

}

For editor scripts you should use Handles instead (or possibly Gizmos if that's possible (Handles are usually better though)).

Drawing should be done in the OnSceneGUI function

I also had the same need for a 2D grid, but after trying (and failing) to wrap my head around OnSceneGUI, OnInspectorGUI, Handles, etc. I finally found this tutorial which very quickly and easily draws a 2D grid using Gizmo.drawLines.

During my attempts with Debug.DrawLine, it drew a lot of power from the editor because I must have been rendering the lines far too many times per frame, but this Gizmo-way of doing it seems a lot more efficient.

Of course there is no function to clear the Debug.Drawline but if you pass duration as Time.deltaTime then there will be no multiple draw of the line if you drawing in every frame.

 Debug.DrawLine(start, end, Color.white, Time.deltaTime);

Debug.DrawLine only draws the lines that you specifically tell it to draw, and only on the frames you tell it to draw them. There is no way to "clear" them, because they don't "stick around".