In case your question was more basic, there are modules
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/User-Defined_Functions_and_Modules
.
So you can do:
module ten_steps() {
for ... // your code that does the n/10 steps
}
for(i=[0:10:100])
translate(whatever)
ten_steps();
In theory the first run of ten_steps() will create the cached object, so it
should not need to be regenerated.
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/reusing-unions-objects-tp16464p16473.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On 14. mars 2016 03:28, MichaelAtOz wrote:
for(i=[0:10:100])
translate(whatever)
ten_steps();
In theory the first run of ten_steps() will create the cached object, so it
should not need to be regenerated.
This comes at a considerable cost, does it not? The cache needs to be
somewhere. When I look at the memory use in an OpenSCAD run it tends to
just increase and rarely (never?) decrease. If the model is large
enough, the memory requirements can cause crashes. In such cases it
would be better to have an option to disable caching.
Carsten Arnholm
I think that is just the way C programs work. As the heap expands it page
faults and the OS allocates more virtual memory. When you free some
object's memory it just gets added to a lists of free chunks for reuse by
the heap manager. It doesn't shrink the virtual address space as it would
leave a gap in it. If it doesn't get used then the OS might page it out,
freeing up physical memory, but the virtual space only ever increase.
On 14 March 2016 at 17:48, Carsten Arnholm arnholm@arnholm.org wrote:
On 14. mars 2016 03:28, MichaelAtOz wrote:
for(i=[0:10:100])
translate(whatever)
ten_steps();
In theory the first run of ten_steps() will create the cached object, so
it
should not need to be regenerated.
This comes at a considerable cost, does it not? The cache needs to be
somewhere. When I look at the memory use in an OpenSCAD run it tends to
just increase and rarely (never?) decrease. If the model is large enough,
the memory requirements can cause crashes. In such cases it would be better
to have an option to disable caching.
Carsten Arnholm
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 14. mars 2016 19:10, nop head wrote:
I think that is just the way C programs work. As the heap expands it page
faults and the OS allocates more virtual memory. When you free some
object's memory it just gets added to a lists of free chunks for reuse by
the heap manager. It doesn't shrink the virtual address space as it would
leave a gap in it. If it doesn't get used then the OS might page it out,
freeing up physical memory, but the virtual space only ever increase.
No, this is not generally true. I've written many programs that release
memory along the way, and it shows up as reduced memory footprint in the
operating system. It depends on how programs are written.
However, regardless of how an application returns memory to the OS (or
not), the fact that OpenSCAD keeps consuming more and more memory, means
there is something not quite right, because it really should not be
required.
For the "many holes" example posted by Maël Naccache 03. march, the
memory requirement in OpenSCAD generally just grows in one direction
(up) to more than 900MB (Win7 2015.03-2). For the same example, in my
experimental implementation using carve, the memory use rises and falls
many times between 50-150 MB only, the final results are similar in
resolution. I don't know what OpenSCAD does here, but the memory use is
clearly not optimal. If this has to do with caching I cannot say, but I
would check it.
Carsten Arnholm
On Mon, 14 Mar 2016 18:10:42 +0000
nop head nop.head@gmail.com wrote:
I think that is just the way C programs work. As the heap expands it page
faults and the OS allocates more virtual memory. When you free some
object's memory it just gets added to a lists of free chunks for reuse by
the heap manager. It doesn't shrink the virtual address space as it would
leave a gap in it. If it doesn't get used then the OS might page it out,
freeing up physical memory, but the virtual space only ever increase.
In the Linux case at least that is configurable. It doesn't normally
matter however as any unreturned memory will be idle and so just dumped
out to swap when other processes need RAM.
Alan
cacb wrote
When I look at the memory use in an OpenSCAD run it tends to
just increase and rarely (never?) decrease. If the model is large
enough, the memory requirements can cause crashes. In such cases it
would be better to have an option to disable caching.
Design/Flush_caches
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/reusing-unions-objects-tp16464p16497.html
Sent from the OpenSCAD mailing list archive at Nabble.com.