Check your glassware, make sure that they are beer clean. If your glassware is dirty, or has a residue that could lead to an overly large amount of co2 nucleation sites and cause your beer to flatten faster.
FWIW, I do no put any of my beer glassware in the dishwasher. I wash it all by hand, thoroughly rinse it and make sure to dry and polish the glass with a clean towel that does not have any fabric softener in it.
Also, under carbonation can be an issue, if your carbonation levels are low, you will find that you don't have much left in the glass toward the end.
Most common is that the beer has not been carbed at the proper temperature or length of time. Too high a temperature can kill the yeast before they finish carbing up the beer. Too low a temperature will cause the yeast to carbonate the bee very slowly, or even cause the yeast to go dormant before carbonation occurs. Too short a time will obviously does not allow enough co2 to dissolve into solution for proper carbonation.
There are many issues that can cause the problem you describe, but what I have listed above IMO, are the most common to look into first.