Stack Commit Size, Stack Reserve Size

Kernel, Loader, code execution and working with memory

Re: Stack Commit Size, Stack Reserve Size

Postby Josef Templ » Tue Oct 16, 2018 5:00 am

Did you relink a new blackbox.exe file for the test?
Module Kernel is part of the linked executable.

- Josef
Josef Templ
 
Posts: 211
Joined: Tue Sep 17, 2013 6:50 am

Re: Stack Commit Size, Stack Reserve Size

Postby Mobatec » Thu Oct 18, 2018 1:03 pm

Anyone any suggestions for the original question? I'm rather stuck and would really like a solution

- Mathieu.
User avatar
Mobatec
 
Posts: 14
Joined: Thu Oct 11, 2018 3:20 pm

Re: Stack Commit Size, Stack Reserve Size

Postby Mobatec » Thu Oct 18, 2018 1:06 pm

Oh, sorry, I didn't notice that after 10 comments I had to click to the next page :geek:

Yes, Josef, I relink new blackbox.exe for testing.
User avatar
Mobatec
 
Posts: 14
Joined: Thu Oct 11, 2018 3:20 pm

Re: Stack Commit Size, Stack Reserve Size

Postby Josef Templ » Sat Oct 20, 2018 8:27 am

Mobatec wrote:Oh, sorry, I didn't notice that after 10 comments I had to click to the next page :geek:

Yes, Josef, I relink new blackbox.exe for testing.



When you open the file dialog, is the stack almost empty or is it almost full?

It would be good to have a small test program that we can use for
reproducing the behavior.

The only other idea that I currently have is to avoid the large stack by allocating large data structures on the heap.
This would give you much more memory but it is of course a change in your model loader.

A very large stack has at least one additional disadvantage: it slows down garbage collection a lot
because it introduces a huge number of roots. Note that in BB the stack is collected using a conservative
(not a precise) approach. Anything on the stack that looks like a pointer is treated like a pointer
and may keep otherwise unreachable objects alive.

- Josef
Josef Templ
 
Posts: 211
Joined: Tue Sep 17, 2013 6:50 am

Re: Stack Commit Size, Stack Reserve Size

Postby Mobatec » Mon Oct 22, 2018 10:03 am

How do I check if the stack is empty or full? I don't have much experience with this.
In the end, all I need is that the .exe behaves as it should AND that I can load my large models. So, I like your idea about allocating large data structures on the heap, but also here I don't know how that works. I currently make use of the Externalize and Internalize routines of Stores..
- Mathieu.
User avatar
Mobatec
 
Posts: 14
Joined: Thu Oct 11, 2018 3:20 pm

Re: Stack Commit Size, Stack Reserve Size

Postby Mobatec » Thu Oct 25, 2018 7:28 am

Josef Templ wrote:The only other idea that I currently have is to avoid the large stack by allocating large data structures on the heap.
This would give you much more memory but it is of course a change in your model loader.


Hi Josef,

Any hints on how to do this?

- Mathieu.
User avatar
Mobatec
 
Posts: 14
Joined: Thu Oct 11, 2018 3:20 pm

Re: Stack Commit Size, Stack Reserve Size

Postby Ivan Denisov » Sun Oct 28, 2018 7:13 am

Mobatec wrote:
Josef Templ wrote:The only other idea that I currently have is to avoid the large stack by allocating large data structures on the heap.
This would give you much more memory but it is of course a change in your model loader.


Hi Josef,

Any hints on how to do this?

You can use ARRAY buffers and riders above them. Ilya Ermakov said, that he had used something like that to increase the efficiency.
For example, if you have some list structure of with 10000 REALs you can create the ARRAY and then access to this list items by id etc. Try to experiment with your data model to reduce calling NEW and amount of POINTERs. I think, that Josef meant this.
Anyway, can you make some example module for demonstration?
User avatar
Ivan Denisov
 
Posts: 231
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: Stack Commit Size, Stack Reserve Size

Postby Mobatec » Sun Oct 28, 2018 12:31 pm

Hi Ivan,

A bit hard to give an example module. To have an idea about what our models look like have a quick look at this video: https://www.mobatec.nl/web/videos/Mobatec_Modeller.webm

What we store is a mixture of a lot of information in a "Mobatec Modeller Model": Graphical, mathematical, numeric, preferences, etc. When a model becomes big, there is just a lot of information to be stored. I'm not talking about accessing the information of a loaded model, btw, I have implemented HASH tables for quick access of information. The question was on loading a big model into memory, which at one point resulted in a Stack Overflow message. I then increased the Stack Commit and Reserve size of the executable, which had as a positive result that I could load my big models, but the negative effect is that the Windows Explorer apparently has to little memory to work correctly. I was looking for a solution for the latter

The package that we've build over the years consists of over 100 Component Pascal modules. Making an "example module for demonstration" would be missing the point of the question (I think). I hoped there would be some "settings" in which I can load big models and also the Windows Tools would work properly. The DevLinker part unfortunately goes beyond my knowledge, hence the quest for some help :ugeek:

- Mathieu.
User avatar
Mobatec
 
Posts: 14
Joined: Thu Oct 11, 2018 3:20 pm

Re: Stack Commit Size, Stack Reserve Size

Postby Josef Templ » Tue Oct 30, 2018 4:39 pm

if the stack grows very big than you have either a very deep recursion, ie a lot of active procedure frames on the stack,
or you have large local arrays of some data (, or both). Most probably you have very large arrays as local
variables on the stack and a moderate level of nesting or recursion.
Try to allocate those local variables not on the stack but on the heap.

An example: instead of using the following pattern:

Code: Select all
PROCEDURE LoadSomething(...);
  VAR arr: ARRAY 100000 OF REAL;
BEGIN ...

use this instead:
Code: Select all
PROCEDURE LoadSomething(...);
  VAR arr: POINTER TO ARRAY OF REAL;
BEGIN arraysize := ...; NEW(arr, arraysize);

where arraysize is either 100000 (as above) or the precise number
of elements if you know them in advance, which is usually the case.

- Josef
Josef Templ
 
Posts: 211
Joined: Tue Sep 17, 2013 6:50 am

Re: Stack Commit Size, Stack Reserve Size

Postby Mobatec » Wed Oct 31, 2018 9:55 am

Thanks for the suggestion, but the large arrays that I use are already in a dynamic form and take the actual size. I always try to minimize the allocation of new objects. There is quite a deep recursion, though.
There are typically a lot of smaller arrays in my models, not several large ones.
For example a "system" has a pointer to a parent, child, left and right system. Each system holds a lot of information, both local information and pointers to global information. When a model becomes big, there are many thousands of these systems. So, even if I find a way to slightly improve the loading of a model, I will still run into a stack overflow problem if the model becomes big. Is there not a way to just overall assign more memory to BlackBox?
User avatar
Mobatec
 
Posts: 14
Joined: Thu Oct 11, 2018 3:20 pm

PreviousNext

Return to System

Who is online

Users browsing this forum: No registered users and 0 guests

cron