1 - What is a leakYou see that blackness in the 3d view in hammer, it's called the void. Think of the void as outer space and think of your map as a space ship. If there's any holes between your space ship and space everyone's going to die. Well if you load up your map in tf2 and your map has a hole (leak) where you can see the void, well for one it's not a pretty sight seeing the void, but also it causes your whole map to be very laggy. So we need to find out how to find leaks and fix them.
2 - How leaks occurAs I said before, leaks are caused when theres a hole between the inside of your playable map and the void. Your map can only be sealed by solid blocks, so if there is a brush entity or a point entity (like a light) outside or trying to be a wall to seal in your map, it will cause a leak. (One other thing, displacements and water also don't seal in the map).
3 - Finding leaksThe simplest way to find a leak in your map is to use one of the tools in hammer called the point file. To generate a point file, compile your map with these settings:
Once its compiled. Close the compile log and click on map > load point file (point file, not portal file). If you get this message showing then well done, your map has a leak (or many).
One thing, I doubt your user name is Andrew and your map is called t1, but you get the idea. Alternatively, if you get this message showing, then you have no leaks and have nothing to worry about. (you can just close it).
So now, back to that message that means you have a leak, go ahead and press yes to load the point file.
Oh look, a red line has been drawn in your map. This shows you a path between an entity and the void. (your map has to have at least one entity in it to actually cause a leak). Although this is a really obvious example, I'll show some more complicated ones later on. So of course to fix the leak in my current map I need to put in the walls I forgot to add. Problem solved.
Remember to compile again and load point file to check that there aren't more leaks in your map. Once you get the message meaning there are no leaks, click map > unload point file.
4 - Complex leaksLeaks as I said before, can occur in different ways. Take this example here:
Lolwut, the red line is going straight through a wall. As I said before, brush entities can't seal the world, and oh look, that wall is a func_brush. To fix this leak, we need to add another solid block behind it to seal the map again.
Another example of a complex leak is as shown:
As you can see here, it would appear that the red line is starting and ending in the void. This one needs some understanding about brush entities first. Brush entities have an origin, a centre point. This centre point is generated depending on the brush entities size and position, but it can sometimes end up lying outside in the void as shown in my example here:
Now that you understand what is causing the leak, the simplest way to solve it is just to add a small block that covers the origin:
There we go, when I compile and load point file again, no leaks! As you may have figured out from this, it is actually possible for example to cover your whole map in a brush entity (a trigger_hurt for example) and still have no leaks so long as the centre origin of the entity is covered. Neat eh?