I feel like the memory consumption constraint has never been raised and properly discussed before this blogpost:
It is good to have this pointed out even if it is somehow strange that in comes in the form of a blogpost and so late.
The blogpost says:
When adopting such a batching pattern, one should bear in mind that, whenever N orders sitting at the request script are consumed within a single transaction, the request script will be executed N times on transaction submission. Moreover, the memory limit check (triggered when the transaction is submitted) is realized by aggregating the memory consumption for each single request script execution, for the main script execution, and for any MintingPolicy scripts that may also be executed (i.e., according to protocol design).
My questions are:
Why is the memory consumption the aggregate of all scripts executed ? The result of any given script is a boolean and there is no possible dependency of one script to any other (as no script can access any other as you can verify in the Plutus API). Why does the node need so much memory ? Why doesn't it just need the memory needed for the largest script. The memory could be cleared after each script execution.
How can we compute the memory consumption of a script ? An approximate method would help too.