Multi-World and/or Multi-Thread

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Multi-World and/or Multi-Thread

Postby JernejL » Mon Dec 14, 2009 8:58 am

Gianluca wrote:Do you introduced a new function "SetMemorySystem", but what's the purpose ??


You can now use it to set to have newton use your own malloc / memfree unified memory manager for all worlds, since memory management is not per-world anymore.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Multi-World and/or Multi-Thread

Postby Julio Jerez » Mon Dec 14, 2009 9:09 am

the mumber of of allocators is equal to the number of world plus the global allocator.
The global allocator is for stack allocation, fix memmory blocks, and some other thing I do not remember. teh locla allocator is for runtime allocation of fix size samll chunks.
with the old format NewtonCraete (allc, free) I only had two choces:
1- set the allocators function to system malloc and free, and the local allocator function of the new world to the alloc and free passes to newto create, but tha will not report back the total memory use by Newton
2- set the allocators funtion of the of teh global allocator for each call to newtonCraete, but is could be very bad if some one decide to pass different allocators function to different worlds,
because another a world may have already some data that coudl no be free form eth matching free.

another solution would be to add a third funtion SetGlobalAllocator, but the then will make the engine complicated since the application programmer can get confused as to what allocator is waht,

I decided to use that but with a twist to eliminated teh complication, world use the allocator funtion of the global allocatior.
of course this may alse cause problems if some one change the global allocators funtion after a world is crated,
but that will be something the applicator did wrong since SetAllocator should be called once before the creation of any world.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron