Maybe that's the problem. I use GlobalAlloc when I know the size of the array, solve the problem, then use GlobalFree to free the memory. When I get a new vector size I again use GlobalAlloc thinking that I freed it previously and, therefore, should use GlbalAlloc as if creating a new vector...