Weed and DMT are completely different.
First of all, if you smoking any "PURE" compound, like extracted spice, all the smoke is your compound, so whatever leaves your lungs is wasted product. There is a limit to how much can cross your lung/blood barrier at a time, so the longer you hold your breath the more will be absorbed. What helps is to take quick inhales while holding your breath, you push down the compound to be absorbed more. The reason for this is that there is lots of "residual space" in your lungs: meaning areas where gases are not absorbed, so for maximum efficiency, you keep inhaling after taking your hit, so the oxygen coming in stirs up the gases even more and pushes everything down into the absorbtion zones for maximum absorption into the blood stream. An example of the biggest residual area is your trachea and the first few branches of the bronchi - huge volume of gases can be contained in these areas. If you just inhale your hit, and hold it there, quite a lot of it will just be sitting in those areas not being absorbed, and it will come out when you exhale. The extra inhale (of air) after you've taken your hit makes a bit of a difference.
The different with weed is that generally your smoke mainly consists of lots of useless plant material, stuff you DONT want to be inhaling. THC is quite readily absorbed, but holding it in for even a few seconds longer than usual will be MUCH more effective. This is even more true for when using a vaporizer. I always hold in my hits for 10-20 seconds with a vaporizer, and it's no myth...it DOES work much better, that's just the basic chemistry/physiology behind it.
How long do you need to hold it in? Depends on how efficient your lungs/blood flow are. I know some people who don't need to hold it in for long, and on the exhale they have barely any noticeable smoke exiting, whereas in my experience I can hold it in for 10-20 seconds and still see some small amount of smoke.
Again, the rule of thumb, especially with pure compounds...if you see smoke coming out on the exhale, that means you should have held your breath for a bit longer, since that's all dmt that wasn't absorbed. And if you hold your breath too long with weed, that means you're taking in all the plant materials, tar, harmful carcinogens that you shouldn't be. I switched to vaping a long time ago, I really don't enjoy joints as much, or bongs. Feels so nasty on the throat. Never been a fan of "smoking" anything.