Locks are usually held until commit time, except advisory locks iirc but those have to be explicitly checked, so if you don't know if you are using them you probably aren't.
Long-running transactions are generally a problem particularly when you have idle blocks of space between them. Try shortening your transactions and see if that helps.
Best Wishes,
Chris Travers