if you hold in your hotbar something that gives an attribute when held, and wear an item with the same attribute, once you stop holding the item the attributed effect will stop even though the item you are wearing is still effecting you.
an example to this is when you give your self this item:
/give @a minecraft:leather_boots 1 0 {display:{Name:"Pain boots"},Unbreakable:1,HideFlags:4,AttributeModifiers:[{AttributeName:"generic.maxHealth",Name:"generic.maxHealth",Amount:-10,Operation:0,UUIDMost:46940,UUIDLeast:113831}]}
equip it and hold it, once you stop holding it even though it is still equipped you get your hearts back
Use different UUIDs.