Out of memory when drawing a path on canvas that is much larger than the screen

My solution for this issue might not be the cleanest but did what i needed. I used canvas.drawLines, which lefts not connected intersections between each line but does work much smoothly.

float[] pathArray = new float[(nodes.size() - 1) * 4];
for (int i = 0; i < nodes.size() - 1; i++) {
    int index = i * 4;

    Node from = nodes.get(i);
    pathArray[index] = from.x;
    pathArray[index + 1] = from.y;

    Node to = nodes.get(i + 1);
    pathArray[index + 2] = to.x;
    pathArray[index + 3] = to.y;
}

With this way we can create our "path".

then draw it to the canvas as below;

canvas.drawLines(pathArray, mDefaultPaint);

As i said outcome will be broken links between lines but there will be no oom issue