fix memory leak

checkPortRole: do not store every object's links, only the last one's