Neither will have a significant impact on memory however.
You should rather choose the approach that's most flexible to you.
If your object won't always follow the entire path (a moving platform may revese diection when colliding with a wall), go with code.
If you have a parameterized path (paramete of path size for example), then go with code.
If you have a complex path with little regulaity, then go with paths.