Simple test files for Dynamic Loading (2.55) - Updated

:evilgrin:hey,
i have a simple setup showing the very basic dynamic loading technique.
this may be useful if you haven’t tried it before.
Anyway, download the two files and open the main.blend , press P to play (make sure that both files are
in same folder)

SETUP #1:
in this setup, another scene from another blend file is appended to the current Scene dynamically. it can be later removed.

press space bar to dynamically load the mesh and right Alt to unload/fee.:mad:
also check out the console window :eek: this may be useful.:stuck_out_tongue:

SETUP #2:
down there.:smiley:
on post #10

More Tests files are coming soon…:o
Many thanks to Monster and Moguri for clearing some doubts on this.:yes:
if the setup didn’t work for you please let me know.

Attachments

main.blend (58.9 KB)lib1.blend (529 KB)

Hi, I dont know if you are aware of this. But every time i load and unload the lib from main.blend the memory consumption keeps on getting bigger.

hmmn seems like the “try:…except:” thing was causing the problem.
i think i fixed it now.try it now.
thanks.

Sorry dude, the problem still seems to there :confused:

Running win 7 64bit.

I can’t find in the api libList() function… Maybe it raise the problem (if it isn’t complete, it may return nothing, so your list just have a string useless for libfree). I haven’t understood well the libfree function yet, so i’m not sure how to manage it, but maybe you can create the list of loaded lib while loading them :wink:

I cant figure this out.
Anyone else got the same issue?

I’m having the same issue with it. I tried rewriting the file a bit differently but the same issue persists. Running Vista 32 bit here.

Blender is still holding on to the data while game engine isn’t even running. I realized this when I was writing my version of the file. I stopped and started the game engine about a dozen times and loaded and unloaded libs every time. My memory consumption was up to about 122k (as apposed to the usual 48k) by the time I was done and it took blender about 1 minute to shut down.

I tried making a runtime of it and it still held onto the data like before. Also, it has nothing to do with the ListLib() function, because I don’t have that in my .blend. I’m wondering if it has to do with the fact that we aren’t using the LibNew() function, but the LibLoad() function. It would be great if Campbell or someone else in the know could comment on this to give us some clarification.

EDIT: Played with it some more. If you open up your lib .blend and the load .blend at the same time, (in two seperate instances of blender) and launch the game engine in the load.blend, and then load/free the scene, you can’t edit and save in the lib .blend even though it should be freed. Blender will not allow you to do so since the load.blend has the file open. That’s not what should be happening (as far as I understand it at least) The LibFree() is definitely not freeing the scene data.

Attachments

load.blend (329 KB)lib.blend (419 KB)

why is it always me?
that thins work with me won’t work for others and vice versa.

@GGentzel
i checked out your files.
i could see the issue on your file.
my memory consumption was getting bigger.
but…but i reduced back fine after i closed the blender.

i think the possible reasons might be:

  1. we are dealing with dynamic memory allocation via pointers indirectlyand deallocation, which means if we aren’t careful memory leak could occour.
  2. the weird behavior/results may be explained like this:
    * if the LibLoad() is called multiple times, memory consumption can get high, coz the previously loaded library is not freed from the memory
    before it is called again.
    * if the LibFree() is called if no library is already loaded, the pointer may be pointing to some random location in ram ,and cause unexpected memory leak
    * to solve this issue make sure that the libraries are properly freed/loaded before/after the respective functions are called.
  3. LibList() is really essential, else there is no pint in using LibFree() [ i mean how are we suppose to free something, if we don’t know what is loaded]
  4. are these functions made possible via C\C++ ? [they better be]

i will put up a video today or tomorrow showing the results i am getting.k

NEWS: i recently checked out the api and found that the “Action” data block is also included [hurray:D!]
which means dynamic animation possible?

Hey nice setup you have here. I did something similar for my game and it works fine. But I always read this thread as it has really helpful information. Thanks for that.

SETUP #2:
this one loads the mesh data block from another blend file and uses it to replace the mesh of the object Cube.

press space bar to load & X key to unload/free.

Attachments

main_2.blend (517 KB)mesh_lib.blend (332 KB)

Yeah, it’s quite possible.
If the c/c++ code use a malloc to allocate a custom struct that works like a blender library, our liblist would be the list of pointers to our library and libfree would free the memory. So if we forget to free the memory some memory leaks may occur, but the liblist would work like a garbage collector, so that each x frames we control what library is really needed and free the rest. Instead, reading from the api, it seams that libfree works only on library created by libnew… So there are 2 ways:

  1. create a new library with all the unneeded elements and free that (i don’t know if it is possible)
    2)we give the wrong argument to libfree

In your first example the path written in the console was C:\Folder\file. Maybe there’s some bug sotring paths, or with some function, and libfree didn’t recognize it. I’ll try if giving to libfree “C:\Folder\file” works…

can you link the liblist funtion from the api? I can’t find it! Thanks :slight_smile:

well ,it worked only like that path earlier.

so far they haven’t included the libfree in api [ may be it is unstable and likely to be changed ]

Yeah in my file too the memory gets just little bigger if it the LibFree is called.

For example:
at start: 712 MB
load lib: 990 MB
free: 716 MB

so there’s 4 MB more than at start.

Anyway here is my example I use for my game
http://www.gtown.ch/de/entwicklung/file-liste/Tutorial-Files/Gtown_Lib.zip/

just open levels/Lib_level.blend

Note: you need to load larger files as in the example if you want to see the mem consumption. Just replace the name in the lib_list.py script

i checked out your file and it worked as i expected.
the Dynamic culling system is looking good.

For me my setup works fine, it only adds about 2 mb of data to ram and frees it.
first i thought that i could show it be recording it .but later found that the recording software stores the recorded data to memory and it get big. so that didn’t worked well.
any way i’ll do more tests on this untill i figure out the Dynamic terrain like that made by ideasman42.
Also it’s become hard to debug. one has to check that there is no memory leak occurred.

i also did some tests on the real-time physics constraints and it was splendid.

Ideasman42 did a strange thing: his script loaded a .obj file, converted it in a blend library, then loaded it… I don’t think it’s the most common workflow for blender ge users :wink:

man he is a pro. besides he implemented the Dynamic Loading.

Check this out :stuck_out_tongue:
This could be interesting to watch.

Hey the vid is cool.

We don’t have to forget that blender 2.5 is still in development and has a lot of bugs. Perhaps it will run as we like if 2.5 stable is out. Who knows???

Dude, great work. In addition with what i’ve just finished, it can do great things!!
Here the video! (i’ll share the blend once finished with he dynamic loading too)

It adds many squares around the player, and each squares can load a different part of a big terrain(that can be divided in multiple blends), creating a culling system for the terrain(and if you have different lod of your terrain, it can also load different meshes if in different positions). It also add a different mesh if the player goes out of the limits of the map

Did you managed to free the memory?

Wow that was cool.
it seems everything can be controlled there.keep up.

Of course i managed to free memory.
i’ll wait till blender is fully stable:D

Do you mind posting the blend files you used in your video? :slight_smile:
They would be excellent to learn from!!