Is there a way to remove the gap between window edge and the screen edge when the Dock is hidden?
Not yet (as of macOS Sierra 10.12.6). When hiding the dock, the OS still leaves ~4 pixels of visible space presumably reserved for some part of the dock behavior. Third party window resizing doesn't seem to help either. Creator fifafu of BetterTouchTool wrote:


  You mean the gap when the dock is hidden? Unfortunately this is a
  limitation given by the system :-(. I haven't found a way to
  workaround that.


Note: This is more noticeable on lower resolution external displays (4px on a retina display is barely visible). 

Some workarounds:


Move the window over the visible pixels, then drag from the opposite side (but also notice the additional delay in showing the dock)
Use an external display and set a different monitor as primary (drag the white menubar in the display arrangement in sys prefs), allowing full sizing on the non-primary display.


Related Apple SE but for visible docks: Force windows to be maximized but not fullscreen?



Have others noticed? Yes, lots. Macrumors dead ends:

https://forums.macrumors.com/threads/bottom-dead-space-with-automatic-hidden-dock.1716910/
https://forums.macrumors.com/threads/hiding-dock-still-leaves-a-few-pixels-unused.1208427/
https://forums.macrumors.com/threads/how-to-remove-space-between-window-and-dock.1094679/
https://forums.macrumors.com/threads/hidden-dock-small-space-in-the-bottom-of-the-screen.931858/

It's even caused bug reports for OS X app developers:

https://github.com/eczarny/spectacle/issues/555
https://github.com/fifafu/BetterTouchTool/issues/672
https://github.com/search?q=mac+dock+gap&amp;type=Issues&amp;utf8=%E2%9C%93



I'll add that this issue exists vertically as well:





Manual workaround