One Dimensional Example

f[x_]= (x^2) Sin[x - 0.01 (x^2)]+1.1(x^2)+x
Plot[ f[x],{x,-15,12}]

i=0;
Reap[NMinimize[f[x],{x},
StepMonitor:>(i++;Sow[x])]]

NMinimize[f[x],{{x,-10,-8}}]

Two Dimensional Example

i=0;
pts = Reap[
NMaximize[-(1-x)^2-100(-x^2-y)^2,
{x,y},
StepMonitor:>(i++;Sow[{x,y}])
]
][[2,1]];
pts =Join[{{-1.2,1}},pts];
i
Length[pts]

ContourPlot[-(1-x)^2-100(-x^2-y)^2,
{x,-1.3,1.5},
{y,-1.5,1.4},
Contours->Table[-10^-i,{i,-2,10}],ColorFunction->(Hue[0.5*(Log[10,-#]+11)/13]&),ColorFunctionScaling->False,
Epilog->{Arrow[pts],Point[pts]}
]