Link to home
Start Free TrialLog in
Avatar of olegsp
olegsp

asked on

beginthread and paging file size

I am using _beginthread in my program with a classical statement like:

_beginthread(start_func, 0, this);

where "start_func" is some static class member, and "this" points to another class from where beginthread is called. When I first compiled and ran the program (VC 6.0, Windows NT), my beginthread kept failing with error code 1455 - "insufficient paging file size". I had to TRIPLE the paging file size before this problem disappeared.

Why does it need so much space (virtual memory, I assume)? Is this anyhow related to the actual size of the class pointed by "this" that I am passing to the thread (even though I am passing a pointer) ??
Are there any other ways to minimize the amount of virt. memory required by a thread without inflating the paging files???
Avatar of nietod
nietod

There is not inherent reason why starting a 2nd thread would need a lot of memory.  (bassically the only memory it needs is the space used for the stack, a minimal amount of spaces used by the OS to record ifo about the thread and a minimal amount of space used to store thread-specifc RTL info.)  So there must be something you are doing in your thread, or other parts of your program that is requiring this memory.  Like are you creating lots of local variables or large local varaibles?

There isn't much we can say to help you without knowing more about your program and this class.
Avatar of olegsp

ASKER

Yeas, this might be the case, since I was copying some data into the thread to avoid potential sharing conflicts with the main application. As far as I know, a thread will allocate its own address space withing the address space of the main process, so (correct me if I am wrong)
1. If I pass a pointer to a thread, the thread will duplicate this pointer (32 bits) but not the object it points to?
2. If some object has global scope, and I use it in a thread, will it be replicated by the thread or not ?

I guess I am driving to "If I need to pass a lot of data to a thread, should I use pointers, global scope variables or anything else" ?
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of olegsp

ASKER

Thanks, you've answered to all my questions.