Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TedMar, AndrewAMD), 1,344 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
memory management #373951
06/14/11 14:44
06/14/11 14:44
Joined: Jan 2010
Posts: 150
iran - tehran
F
flatron Offline OP
Member
flatron  Offline OP
Member
F

Joined: Jan 2010
Posts: 150
iran - tehran
hi
i try to use malloc && free for entity.
i want to alloc memory for an entity and then free memory.
how can i use malloc for entity?
how do i use sizeof?

Re: memory management [Re: flatron] #373958
06/14/11 15:27
06/14/11 15:27
Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
you do not need to use malloc for entity

ent_create and ent_remove does the memory management for you


3333333333
Re: memory management [Re: Quad] #373959
06/14/11 15:51
06/14/11 15:51
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
From the manual:
"After an entity is removed, its file content is still stored in a cache for faster creation of entities of this type."

Maybe he don´t want this behaviour?


no science involved
Re: memory management [Re: flatron] #373960
06/14/11 16:02
06/14/11 16:02
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
The thing is, you don't manage the memory for your entities. You use ent_create() and ent_remove() (or ptr_remove()) and let the engine manage the entities memory. The reason is that the entity needs to be registered within the engine, the struct needs to be initialized, and the model must be loaded from the file or the cache.

About your last question, you use sizeof() to determine the size of a datatype, for example sizeof(int) would return the size needed for an int which is 4 bytes. However, sizeof() is built into the compiler and not a runtime function so the compiler will replace it with a constant value, this is because Lite-C is a subset of C which is statically typed so at runtime all information about the data is "lost".


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: memory management [Re: WretchedSid] #373989
06/14/11 18:39
06/14/11 18:39
Joined: Jan 2010
Posts: 150
iran - tehran
F
flatron Offline OP
Member
flatron  Offline OP
Member
F

Joined: Jan 2010
Posts: 150
iran - tehran
yes i want to clear chache and level_mark & level free is hard to use.
in my project sometimes level_free make crash and sometimes not.so
i want to use this functions for freeing memory.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1