script size - Script Writing - CHDK Forum

script size

  • 4 Replies
  • 2260 Views
*

Offline timgor

  • ***
  • 150
script size
« on: 18 / March / 2015, 17:38:46 »
Advertisements
There is a question:
Is there any limitation for lua script size, number of lines, file size...?
If yes then what is the maximum size?
Does it affect camera performance if it's too big?

Re: script size
« Reply #1 on: 18 / March / 2015, 17:48:40 »
Is there any limitation for lua script size, number of lines, file size...?
Yes - maximum script size is limited by the free memory available in the camera.  Note that CHDK 1.4.0  (or with the use of a "loader" script) makes much better use of that memory by tokenizing the source when the script loads and not storing all of it in memory.
Quote
If yes then what is the maximum size?
That depends on the amount of free memory in the camera - which varies with every camera model.

Quote
Does it affect camera performance if it's too big?
Not really - unless you use up so much memory that other things needed by CHDK or the camera can't load and run.  For example,  the number of shots that can be taken at full speed in continuous modes is dependent on the amount of free memory.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline timgor

  • ***
  • 150
Re: script size
« Reply #2 on: 18 / March / 2015, 19:21:37 »
I had to mention that I have lua script 40kB size. Would it make any memory problem?

Re: script size
« Reply #3 on: 18 / March / 2015, 19:30:43 »
I had to mention that I have lua script 40kB size. Would it make any memory problem?
Depending on the amount of free memory in your camera, you are probably starting to push the limits unless you use a loader script or CHDK 1.4.0.

Here's a couple of relevant threads :

http://chdk.setepontos.com/index.php?topic=12117.msg119184#msg119184
http://chdk.setepontos.com/index.php?topic=10886.msg106908#msg106908
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14125
Re: script size
« Reply #4 on: 18 / March / 2015, 21:27:41 »
I had to mention that I have lua script 40kB size. Would it make any memory problem?
That depends on how much your camera has free to start with.

The CHDK function get_meminfo() will give you information about how much memory is available.

The most relevant values are free_size and free_block_max_size.  These values are in bytes. There isn't a specific known minimum you need free, but if the canon system heap goes below a few hundred KB, you are likely to start getting crashes. CHDK will use other heaps (ARAM or EXMEM) before using the system heap, so if those still have substantial free space, you don't need to worry about reducing the script memory usage.

The lua function collectgarbage('count') will return the amount of memory used by lua, in kilobytes. This does not include the script source. Depending on your script, you may find that calling collectgarbage('step') or collectgarbage('collect') occasionally is required to keep Lua memory use under control. This is particularly true of scripts that generate a lot of unique strings.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal