I'm working on a UI where I want to display many images, too many to have in memory at once. So I'm trying to implement a "paging" system to display a handful of images at a time and only load on demand. I've come up with something that kind of produces the result I want, but the problem is that it basically pegs the processor. I'm hoping someone can help me spot what I'm missing. This simplified version of the code is enough to hit the processor pretty hard (and continuously)
(*Warning: This may lock up your notebook*)
LoadPage[page_] := Module[{i = 0},
Import["someimage.jpg"];
page]
SlideView[Dynamic[LoadPage[#]] & /@ Table[i, {i, 1, 20}],
ImageSize -> Automatic]
My expectation is that because nothing is changing (except for when the slide is changed) that Import should be run once per slide, but it is apparently being run continuously (as evidenced by opening task manager and watching CPU utilization / notebook locking up). Can anyone explain what I'm missing and help me get the CPU utilization under control?