Types/Memory Usage

Blitz3D Forums/Blitz3D Beginners Area/Types/Memory Usage

Gauge(Posted 2004) [#1]
Correct me if i'm wrong, but the first way to do this uses alot of memory, the second way doesn't eat memory until the new player is created, right?

Dim p.player(1000000)

and this way:

type players
field player.player[1000000]
end type

type player
field stream
field etc etc etc
end type

p.players=new Players
p\player[1]=new player
etc



Who was John Galt?(Posted 2004) [#2]
The second way won't eat memory until players is created, then it eats a load of memory even if you only want to store one player handle in it.


Gauge(Posted 2004) [#3]
ahhh, thanks


SoggyP(Posted 2004) [#4]
Hi Folks,

@Gauge: You'll also find that when exiting a program that uses the second style, it'll take forever to free up the memory.

Later,

Jes


(tu) sinu(Posted 2004) [#5]
what if it holds about 10 elements only? would it still be not worth using?
i just like how neater it seems using arrays in types.


Who was John Galt?(Posted 2004) [#6]
Well obviously holding 10 handles won't cost much memory, but I've never found it necessary to work like this. Only reason I can think of is if you want to look up the details of 1 player quickly without doing a search.


SoggyP(Posted 2004) [#7]
Hi folks,

As usual in these circumstances it's worth doing a little testing yourself, because it's fun to find these things out.

Later,

Jes


Gauge(Posted 2004) [#8]
Well I could always dim players by [1000] or so. I want/need a way to point to that player and have access to that players type. Each player will have up to 3 targets/other players they can fight. Without a pointer i might have to do half a dozen for next loops to find that player, then add that times 100 or 1,000 players if that ever became that option.

Of course the dream would be:

kill joe
Select p\name$="joe"
(return p, etc)
voilla!


(tu) sinu(Posted 2004) [#9]
well i was gonna do something like


type player

field moves.PlayerMoves

end type

type PlayerMoves

field MoveName[MovesAvailable]

field MoveType[MovesAvailable]

field MoveAnimation[MovesAvailable]

field MoveSpeed[MovesAvailable]

field MoveAnimation[MovesAvailable]

field MoveMode[MovesAvailable]

end type


but should do it this way?


type player

field moves.PlayerMoves(MovesAvailable)

end type

type PlayerMoves

field MoveName

field MoveType

field MoveAnimation

field MoveSpeed

field MoveAnimation

field MoveMode

end type




thing is the number of moves maywell go into the hundreds so speed is important.