Jump to content


Photo

Gm Dynamic Variables


  • Please log in to reply
37 replies to this topic

#1 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2680 posts
  • Version:GM:Studio

Posted 29 April 2007 - 06:22 AM

GM Dynamic Variables
By Schyler

Links -
[ GMbase ] - [ GMbase Topic ] - [ GMbase Download ]

Information
This is an extension to add/delete variables from memory! It really works. Usaully when you make variables you can make a game lag (500-1000+) where with this system I could make 4000 variables with no lag and could even make more! The download package contains the file you need to use.

Downloads
GMbase Download

Credit
The credit is shown on the GMbase topic or in the extension.

Questions?
PM me with questions and I will post them here (and answer them).
Thankyou.


Schyler.

Edited by Schyler, 29 April 2007 - 06:24 AM.

  • 0

#2 Camman

Camman

    UnReal Software CEO

  • GMC Member
  • 639 posts
  • Version:GM:Studio

Posted 29 April 2007 - 06:46 AM

Good Idea! I'm not on my computer that has GM7 on it at the moment, but when I do get on I'm going to take this for a test drive!
  • 0

#3 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2680 posts
  • Version:GM:Studio

Posted 29 April 2007 - 07:02 AM

Thankyou for the comments.
  • 0

#4 fogger

fogger

    Clockwerk Studios

  • GMC Member
  • 430 posts
  • Version:GM6

Posted 29 April 2007 - 09:27 AM

How did you achieve this?
Using Data Structures? Arrays? a dll?

guess I should download first...

Nice idea BTW

~Pr0n
  • 0

#5 9_6

9_6

    Guest

  • GMC Member
  • 3627 posts

Posted 29 April 2007 - 05:31 PM

Really? Variables make games lag?
That's kind of new.
I always thought calculations and draw functions make games lag.
All those years of using gamemaker and I didn't notice that it is the variables I need to look after!
  • 0

#6 Darth

Darth

    GMC Member

  • New Member
  • 436 posts

Posted 29 April 2007 - 07:20 PM

Exactly what I was thinking 9_6.
  • 0
Game maker 8 Pro

#7 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2680 posts
  • Version:GM:Studio

Posted 30 April 2007 - 07:42 AM

Thankyou.
Who has used or tested it yet?
  • 0

#8 HaRRiKiRi

HaRRiKiRi

    GMC Member

  • GMC Member
  • 1364 posts

Posted 30 April 2007 - 12:19 PM

9_6 && Darth: Well variables are stored in memory, so a large quantity of them could cause lag. Also GM checks variables every step, thus makes lots of variable possibly slow. GM has also large quantity (47) of built-in variables that are checked very step for every object. This makes 47000 checks for 1000 objects every step, just for the built in variables.
  • 0

#9 BrainWare

BrainWare

    Adrenaline

  • GMC Member
  • 791 posts

Posted 30 April 2007 - 12:24 PM

Gamemaker also has to keep track of what type of 'value' (string or real) you assign to a variable, so that doubles the amount of checks.
Correct me if I'm wrong tho, I'm not absolutly sure.
  • 0

#10 9_6

9_6

    Guest

  • GMC Member
  • 3627 posts

Posted 30 April 2007 - 02:17 PM

GM has also large quantity (47) of built-in variables that are checked very step for every object. This makes 47000 checks for 1000 objects every step, just for the built in variables.

<{POST_SNAPBACK}>


Yeah I know that.
Unfortunately there is NO way to control those checks or get rid of them -if you use objects.
You can't just delete direction, speed and gravity and it won't do the calculations per step anymore. (I wish there was an option though...)
Besides just variables without any calculations (and that is what this system is all about) would be one of the least things to worry about when it comes to speed issues...
  • 0

#11 Darth

Darth

    GMC Member

  • New Member
  • 436 posts

Posted 30 April 2007 - 03:38 PM

9_6 && Darth: Well variables are stored in memory, so a large quantity of them could cause lag. Also GM checks variables every step, thus makes lots of variable possibly slow. GM has also large quantity (47) of built-in variables that are checked very step for every object. This makes 47000 checks for 1000 objects every step, just for the built in variables.


GM doesn't check variables every step... Why would it do that? Also the built in variables are built-in and you can't remove them nor the checks. Unless you are saying "Do not make an object, use this extension and make variables" or something along those lines then I do not see how this helps.

I am not ridiculing your extension just questioning it, slightly.

btw, Does this extension use a DLL or GML?
  • 0
Game maker 8 Pro

#12 HaRRiKiRi

HaRRiKiRi

    GMC Member

  • GMC Member
  • 1364 posts

Posted 30 April 2007 - 04:15 PM

BrainWare: That could be true too. (Only Mark knows)
9_6:I agree that there it would be a cool option if you could just turn of unneeded variables. Like a checkbox with every of the 47 variables, and then you could just uncheck unneeded ones. It shouldn't be too hard to do by Mark. Also, I know that its probably the least thing that slows GM down. But it stills affects speed. E.x. if you make a rock object, that has no code, just sprite. And put 1000 of these in a room, then it will slow down. Because it checks very large amount of variables. If there would not be that much variables (only x,y and stuff) then you could probably have up to 5000 of thous objects. But I don't know the speed impact of drawing 5k objects, so don't hold my word on it. But still you could put in more. Ex. using particle system in much faster then using objects for particles. Because particles doesn't have that much variables to check. So drawing 1000 objects, and drawing 1000 particles would show a considerable difference.
Darth:I never said anything about removing GM inbuilt variables. I said that GM has them, and it causes lag. Also GM checks variables to know if they changed or something. I don't actually know, but some time ago something along these lines where asked. And then someone said why it does that.
  • 0

#13 Relinquished

Relinquished

    GMC Member

  • New Member
  • 265 posts

Posted 30 April 2007 - 04:41 PM

Did you use dynamic allocation? Like in C++?
Very good idea, I'm glad someone finally did something about this.

Edited by Relinquished, 30 April 2007 - 04:42 PM.

  • 0

#14 NewDuck

NewDuck

    GMC Member

  • New Member
  • 54 posts

Posted 30 April 2007 - 08:55 PM

I installed the extension, but how do I use it now, there is no help file nor example.
  • 0

#15 Rusky

Rusky

    GMC Member

  • GMC Member
  • 2492 posts
  • Version:Unknown

Posted 01 May 2007 - 01:04 AM

cool idea. it will help some people who use more complicated scripts and stuff. :D
  • 0

#16 ShadowStrike32

ShadowStrike32

    mr. sarcasm

  • New Member
  • 460 posts

Posted 01 May 2007 - 01:29 AM

wont you get overhead with all of the function calls?
  • 0

#17 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 01 May 2007 - 01:46 AM

Yes.
  • 0

#18 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2680 posts
  • Version:GM:Studio

Posted 05 May 2007 - 06:02 AM

It is actually very fast... I ran a test and decided that with 8900 variables my cpu meter ran at 20% but my ram was 100% and i got lag. I than ran that with my method and I got 45% cpu for about 3 seconds at the beginning then got steady 3% extra ram and 5% cpu. It works.
  • 0

#19 Dany

Dany

    GMC Member

  • New Member
  • 150 posts

Posted 06 May 2007 - 11:48 AM

Really? Variables make games lag?
That's kind of new.
I always thought calculations and draw functions make games lag.
All those years of using gamemaker and I didn't notice that it is the variables I need to look after!

<{POST_SNAPBACK}>

I saw a GM[commercial] game,that want's 2GB of RAM!@%*&^%$&^%*&$^%&^!@#$%^&*&%^$#$%^&*(&^%$^&*()Q!!!!
  • 0

#20 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2680 posts
  • Version:GM:Studio

Posted 07 May 2007 - 06:30 AM

I saw a GM[commercial] game,that want's 2GB of RAM!@%*&^%$&^%*&$^%&^!@#$%^&*&%^$#$%^&*(&^%$^&*()Q!!!!

Thats why everybody needs this (oh yeah, I do have 2gb of ram ^_^ )
  • 0

#21 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 07 May 2007 - 03:47 PM

I doubt variables are the culprit for obscene memory usage. It would take a truly ridiculous amount to get any kind effect from them. Also, this extension won't reduce their memory usage. If anything it'll increase the memory that each variable takes up. If you use instance local variables, those are destroyed with the instance. The only thing I could see this replacing is global variables, and no one could possibly make enough of those to have any kind of huge impact on memory usage.
  • 0

#22 IamCalle

IamCalle

    GMC Member

  • GMC Member
  • 444 posts

Posted 07 May 2007 - 04:42 PM

Well, the functions are good to have anyway, and even if the result is small, if probably help. (Specially for older computers, as someone still have today..)

- I get your point though. :/
  • 0

#23 9_6

9_6

    Guest

  • GMC Member
  • 3627 posts

Posted 07 May 2007 - 09:28 PM

I saw a GM[commercial] game,that want's 2GB of RAM!@%*&^%$&^%*&$^%&^!@#$%^&*&%^$#$%^&*(&^%$^&*()Q!!!!

<{POST_SNAPBACK}>


And you want to tell me that only came from the variables or what?
  • 0

#24 Schyler

Schyler

    Noskcirderf Derf

  • GMC Member
  • 2680 posts
  • Version:GM:Studio

Posted 09 May 2007 - 07:06 AM

Yourself, I thought you had already thpught about doin this.... anyway here look:
var_create(string(id)+"_movespeed")
Anyway, tests were done and it works...
  • 0

#25 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 09 May 2007 - 05:02 PM

The string() function is incredibly slow. That is far from a suitable replacement to a local variable.
  • 0

#26 IamCalle

IamCalle

    GMC Member

  • GMC Member
  • 444 posts

Posted 10 May 2007 - 01:55 PM

Hmm.. what would you recommend, Yourself?
  • 0

#27 purple_pixie

purple_pixie

    GMC Member

  • New Member
  • 2647 posts

Posted 10 May 2007 - 02:52 PM

So do you plan on telling people even slightly how this is done?

The "GMBase Topic" states it has 6 functions - only 4 begin var_ so I've nfc what the others are ... any help?

I would say "where's the help manual" but anyone who can't guess what read,write,erase and delete do probably don't need this extension, to be honest.

"The owner did not define the functions" - 1) who is "the owner" and 2) who *did* define them?

And finally, have you compared the speed differences in reading/writing to these variables with GM's inherent variable manipulation?

EDIT: Ok, so apparently there is a "var_create" function - this is not listed in the "auto-complete" box at the bottom, and gives me an "unknown function or script".

EDIT2:
time1=current_time
for (i=0; i < 10000; i += 1)
{
dave=1
}
time2=current_time
diff1=time2-time1
time1=current_time
for (i=0; i < 10000; i += 1)
{
var_write("dave",1)
}
time2=current_time
diff2=time2-time1
show_message("diff1="+string(diff1)+"#diff2="+string(diff2))

diff1=16
diff2=2469

Nice and quick, I see ... [/sarcasm]

EDIT3: And if we make this dave += 1 and var_write("dave",var_read("dave")+1) we increase diff1 by 0 and diff2 by almost 1500

Edited by purple_pixie, 14 May 2007 - 10:26 AM.

  • 0

#28 Darth

Darth

    GMC Member

  • New Member
  • 436 posts

Posted 11 May 2007 - 08:25 PM

purple_pixie what are your results saying you confused me with "Nice and quick, I see..." ...
  • 0
Game maker 8 Pro

#29 Rusky

Rusky

    GMC Member

  • GMC Member
  • 2492 posts
  • Version:Unknown

Posted 11 May 2007 - 10:42 PM

it's called sarcasm.
  • 0

#30 slayer_jojo

slayer_jojo

    GMC Member

  • New Member
  • 181 posts

Posted 15 May 2007 - 07:00 AM

The "GMBase Topic" states it has 6 functions - only 4 begin var_ so I've nfc what the others are ... any help?

I would say "where's the help manual" but anyone who can't guess what read,write,erase and delete do probably don't need this extension, to be honest.

"The owner did not define the functions" - 1) who is "the owner" and 2) who *did* define them?


When it says "The owner did not define the functions" it just means he did not tell GMbase what the extension contains. It's only for documentation purposes. And yes, Schyler is the uploader, the owner and the creator. I agree though, schyler you should probably make some documentation so people will know how to use this.
  • 0

#31 tgohome

tgohome

    GMC Member

  • New Member
  • 122 posts

Posted 16 May 2007 - 04:31 PM

So do you plan on telling people even slightly how this is done?

The "GMBase Topic" states it has 6 functions - only 4 begin var_ so I've nfc what the others are ... any help?

I would say "where's the help manual" but anyone who can't guess what read,write,erase and delete do probably don't need this extension, to be honest.

"The owner did not define the functions" - 1) who is "the owner" and 2) who *did* define them?

And finally, have you compared the speed differences in reading/writing to these variables with GM's inherent variable manipulation?

EDIT: Ok, so apparently there is a "var_create" function - this is not listed in the "auto-complete" box at the bottom, and gives me an "unknown function or script".

EDIT2:

time1=current_time
for (i=0; i < 10000; i += 1)
{
dave=1
}
time2=current_time
diff1=time2-time1
time1=current_time
for (i=0; i < 10000; i += 1)
{
var_write("dave",1)
}
time2=current_time
diff2=time2-time1
show_message("diff1="+string(diff1)+"#diff2="+string(diff2))

diff1=16
diff2=2469

Nice and quick, I see ... [/sarcasm]

EDIT3: And if we make this dave += 1 and var_write("dave",var_read("dave")+1) we increase diff1 by 0 and diff2 by almost 1500

<{POST_SNAPBACK}>


Maybe you should have tried using different types of variables... ? Such as arrays?

Edit:
I just ran my own test. Seems you are right. I manage to create 5000 variables in 50ms. The dynamic method cannot even create 50 variables in 50ms, it did that in 469ms. By my calculations, it could only assign 5.33 variables, approximately, in that time.

Edited by tgohome, 16 May 2007 - 04:54 PM.

  • 0

#32 Chrishowarth

Chrishowarth

    GMC Member

  • Validating
  • 208 posts

Posted 26 May 2007 - 11:15 AM

Wow I considered writing a DLL for this; you have beaten me to it! :P

#33 Marchal_Mig12

Marchal_Mig12

    The Rhouan

  • GMC Member
  • 1182 posts
  • Version:GM:Studio

Posted 30 May 2007 - 05:20 PM

Well I think none have suspected that every variables are in reality binaries numbers. I mean that the computer read them as binaries. So '0' is taking less memory than a higher number as well. So the best way to free a variable after using it is to set it to 0 or to an empty string. As someone said local variables are destroyed with the instance.

You could have know this if you don't already by knowing the C++ base speed issues.

See ya,
Miguel
  • 0

#34 Blastoiseiii

Blastoiseiii

    GMC Member

  • GMC Member
  • 322 posts

Posted 30 May 2007 - 07:18 PM

0 takes less memory than a higher number? Because it is only one digit long? I don't see how the value of the variable would make much of a difference, seeing as the computer would set aside a set of specific digits for a data type (IE it would be 00000000 instead of just 0).

For those of us who studied pascal because they are afraid of touching memory too much, could you maybe explain this C++ speed rule?
  • 0

#35 Marchal_Mig12

Marchal_Mig12

    The Rhouan

  • GMC Member
  • 1182 posts
  • Version:GM:Studio

Posted 31 May 2007 - 07:34 PM

0 takes less memory than a higher number? Because it is only one digit long? I don't see how the value of the variable would make much of a difference, seeing as the computer would set aside a set of specific digits for a data type (IE it would be 00000000 instead of just 0).

For those of us who studied pascal because they are afraid of touching memory too much, could you maybe explain this C++ speed rule?

<{POST_SNAPBACK}>


Okay, I just got to take off my book... He's at my father's home so I'll re-read it and explain everything detailed.
  • 0

#36 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 31 May 2007 - 08:01 PM

That's totally ridiculous. When a variable is defined, it is allocated a fixed amount of memory. It doesn't matter what value you put in that memory, it still takes up the same amount of space.
  • 0

#37 Marchal_Mig12

Marchal_Mig12

    The Rhouan

  • GMC Member
  • 1182 posts
  • Version:GM:Studio

Posted 01 June 2007 - 04:48 PM

That's totally ridiculous.  When a variable is defined, it is allocated a fixed amount of memory.  It doesn't matter what value you put in that memory, it still takes up the same amount of space.

<{POST_SNAPBACK}>


Sorry, I think I'm wrong with numbers. But for strings... Strings don't always take the same memory space. Can someone confirm this?
  • 0

#38 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 01 June 2007 - 06:00 PM

It depends on what string you're talking about. If you use the C++ std::string class, then, no, that isn't always the same size, because it dynamically reallocates memory for the string. A C-style string (char*) must also be dynamically reallocated if you want to change its size. It's not unusual for a fixed amount of space to be allocated for the string in that case because you can usually assume the string will never exceed a specific length.
  • 0