3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: I need some outsider's perspective...
[Re: Carlos3DGS]
#416913
02/05/13 21:30
02/05/13 21:30
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
sys_nxalloc gets it's memory from the nexus while sys_malloc doesn't. But I wouldn't recommend sys_naxlloc anyways because you cannot free memory allocated this way. (Or has this been fixed in the meanwhile?)
sys_malloc and malloc should get the memory from the same source, i.e. the operating system. If the operating system refuses to give the engine more memory it will refuse to give you more memory as well. So it's not plausible that you'll get more memory when using malloc.
But I feel not completely safe talking about this. Maybe someone else can confirm my statements? Superku? JustSid?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: I need some outsider's perspective...
[Re: Carlos3DGS]
#416918
02/05/13 21:36
02/05/13 21:36
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Well, even the nexus could be enlarged, but as I already said, the usage sys_nxalloc should be avoided anyways unless you really know what you're doing.
In fact there is always a limit on the amount of memory you can allocate. But I don't see a reason why the limit of allocated memory should be different for sys_malloc and malloc.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: I need some outsider's perspective...
[Re: Superku]
#416939
02/06/13 07:32
02/06/13 07:32
|
Joined: Dec 2003
Posts: 1,225 germany
gri
Serious User
|
Serious User
Joined: Dec 2003
Posts: 1,225
germany
|
... I assume sys_malloc just calls malloc and adds a few security and error handling "systems" (including the very useful sys_marker instruction that is not supported by the default malloc instruction). Yes and because of that a direct malloc call is faster than sys_malloc. But hey we are in C. If its not neccesary to build large arrays or objects at each engineframe I wouldnt care. Ullllillia would create a benchmark for that and would us overheap with numbers.
"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
|
|
|
Re: I need some outsider's perspective...
[Re: gri]
#416940
02/06/13 08:14
02/06/13 08:14
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
okay, I'm a bit sick to read all the posts but freeing of what I wrote earlier is:
int i;
for (i=0;i<1000;i++) // ###
{
sys_free( Bwater[i] );
}
sys_free(Bwater);
Bwater = NULL;
the last line is only needed if you plan to use again Bwater the 100 in memset is an example value, I copied it from my existing code, where my default value is 100. I use similar arrays and srtuct arrays and array structs and arrayarraystructssctrucscscs  extensively.
|
|
|
Re: I need some outsider's perspective...
[Re: sivan]
#416953
02/06/13 13:39
02/06/13 13:39
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
The last line is not required for a correct code but it's a very good habit to clear vagabonding pointers. This can save you from a lot of trouble.
Still the value 100 will be copied bytewise and hence works only for char arrays. The exception is 0, because four zero bytes are still the number 0 as an int. You can of course use any number that is a pattern cnosisting of four equal bytes.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: I need some outsider's perspective...
[Re: Uhrwerk]
#416994
02/07/13 00:02
02/07/13 00:02
|
Joined: Oct 2008
Posts: 513
Carlos3DGS
OP
User
|
OP
User
Joined: Oct 2008
Posts: 513
|
I purpously closed the program withought freeing the memory allocated out of curiosity to take a look at what you guys said before about the log file. But I found nothing in acklog.txt stating any memory was not freed... Where can I find this information? EDIT: This is what my acklog.txt file looks like Log of A8 Engine 8.20.1 run at Thu Feb 07 01:04:54 2013 KRLOS on Windows NT/2000/XP version 6.1 Build 7601 Options w_map_gen2.c -diag -nx 200 -t_ -debug App: C:\Program Files (x86)\GStudio8\SED.exe in D:\SPHERE\WASTELAND\ MM mixer opened DSOUND device opened DI interface opened Start Window opened(c) Conitec - www.3dgamestudio.comA8 Engine - Commercial Edition V8.20.1 - May 12 2011 Development version Registered to: Carlos Alberto Idrovo Carrillo Mouse found Altavoces (Dispositivo de High Definition Audio) opened ATI Radeon HD 3300 Graphics pure T&L device 1ff9 detected D3D device ATI Radeon HD 3300 Graphics 1ff9 selected. acknet.dll opened ackphysx.dll opened ackwii.dll opened Compiling W_MAP_GEN2.C - [Esc] to abort............. 0.346 sec Running W_MAP_GEN2.C. 3 objects Main started at 1.424 in debug mode D3D_Init Window: 800x600 -> Window: 1x800x600x32 Video memory found: 2032 MB LevelInit at 1.474 0 lmaps 0 textures...ok LevelReady at 1.480 def_startup started Main loop at 1.481.... 1st frame with 2032 MB. at 1.522 Normal exit at 2.806 Close level,DLL,objects Free input,funcs,panels,defs,syns,views,strings,vars..ok Free sounds,bmaps,fonts,hash,defs1,script..ok Close dx,multimedia,D3D,engine,nexus..ok A8 Engine - Commercial Edition V8.20.1 - May 12 2011 (c) Conitec - www.3dgamestudio.comRegistered to: Carlos Alberto Idrovo Carrillo Close window at 2.901
Last edited by Carlos3DGS; 02/07/13 00:10. Reason: added acklog.txt info
|
|
|
Re: I need some outsider's perspective...
[Re: Carlos3DGS]
#416995
02/07/13 00:18
02/07/13 00:18
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
No idea what you did wrong there. Here is an extremely simple example:
#include <acknex.h>
void main()
{
sys_marker("WTF");
void* p = sys_malloc(1337);
sys_exit(NULL);
}
When you execute this snippet and have a look at the log file it says at the end:
[...]
Unfreed: 943, WTF, 1340 bytes
Close window at 1.217
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|