I've only done this once (in BC). We picked out a spot before dusk, sat on the beach for a while, then set up after there were few people around. Left (and importantly left no trace) shortly after sunrise.
As you say its free and you can camp anywhere. But you could get harassed/asked to leave in the middle of the night, you have no shower, and its not ideal to cook.
In Canada I wouldn't do this in a big city - like Toronto. You will likely be asked to leave by cops. In a smaller place I would as others have suggested feel out a local or two. Or set up where you can't be seen. And leave very early.