There isn't any real way to determine if data is allocated on the heap or stack because (under some circumstances in some ISAs) a given memory address can be in either. The only real way is to look at how the memory was allocated. If it was with malloc (or new), then it's on the heap. Otherwise, it's on the stack.