Trying to replace a gridGraph at runtime

Im using this code but its locking up unity:

//set grid size
float nodeSize = 10;
var grid = AstarPath.active.data.gridGraph;
grid.center = new Vector3(mapWidthnodeSize/2, mapHeightnodeSize/2, 0);

    // Updates internal size from the above values
    grid.SetDimensions(mapWidth, mapHeight, nodeSize);

OK i figured it out. Needed to rescan the graph:

AstarPath.active.Scan(grid);