Graphics is disposable class and should be deleted after using:
delete g;