Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in resize array vector.h:295 and vector.h354 #9875

Closed
Ranoller opened this issue Jul 26, 2017 · 3 comments
Closed

Error in resize array vector.h:295 and vector.h354 #9875

Ranoller opened this issue Jul 26, 2017 · 3 comments
Milestone

Comments

@Ranoller
Copy link
Contributor

Ranoller commented Jul 26, 2017

Operating system or device - Godot version:
Godot 2.1.3.
Win 7 32 bit.
3,39 gb RAM usable

I don´t know if an array with 30.000.000 of "0" should freeze Godot, if this is normal I close the issue.

Issue description:
Push back an array with a value of "0" , 10 million times is ok
Push back an array with a value of "0", 30 million times throw:
Vector::push_back: condition 'err' is true. returned: true
Vector::resize: condition '!_ptrnew' is true. returned: ERR_OUT_OF_MEMORY

...And throw this error in loop freezing the program.

If I put other loop before, the freeze is with less iterations.
You can freeze godot with other kind of iterations (above 20.000.000 or 30.000.000 times)
without append nothing to dict or array.

Steps to reproduce:
Use the next code with 10 millions of iterations and 30 millions of iterations.

Link to minimal example project:

extends Node2D
const iterationsnumber = 30000000
func _ready():
        var arraywhile = Array()
	var counter = 0
	var timestamp = OS.get_ticks_msec()
	while (counter < iterationsnumber):
		arraywhile.append(0)
		counter +=1 
	var timestampEnd = OS.get_ticks_msec()
	time = timestampEnd - timestamp
        print ("While loop append to array "+ str(iterationsnumber) +" iterations and int add \"[0]\"  Ticks: 
        "+str(time))
@RandomShaper
Copy link
Member

Possibly related to #8279.

@Ranoller
Copy link
Contributor Author

Ranoller commented Jul 27, 2017

Ok, I made more test in a computer with win7 64 bit 16gb RAM:
Godot 2.1.3.:
64 bit editor can allocate in runtime more that 1gb (I can push an array more that 45 million times, I think that every "null" or "0" push is about 20 bytes.
32 bit editor goes OUT_OF_MEMORY on reach 550 mb, system says that goot continue allocating memory wrongly and slowly, but program freezes and console show the warning in loop. Godot become in loop mode and allocate and free memory until 558.000 and 564.000 kbytes. (I see in system, godot doesn´t have any function that indicates real memory used)

Edit: Other test in 64 bit editor pushing array to 100 million: System says that godot allocate 2 gb of memory. At this quantity, there are only three messages to console and immediately godot closes:
Messages:

ERROR: Vector class Variant ::resize: Condition '!_ptrnew' is true. Returned: ERR_OUT_OF_MEMORY
vector.h:295
ERROR: Vector class Variant ::push_back: Condition 'err' is true. Returned: true
vector.h:354
ERROR: StreamPeerWinsock::read: Server disconnected!
stream_peer_winsock.cpp:202

@Ranoller
Copy link
Contributor Author

Ranoller commented Sep 1, 2018

I will close this because i feel that this is not a real use issue and probably will be fixed by some optimization in typed gdscript when "variant" optimizations initiates.

@Ranoller Ranoller closed this as completed Sep 1, 2018
@akien-mga akien-mga added this to the 2.1 milestone Sep 1, 2018
@akien-mga akien-mga changed the title (2.1.3) Error in resize array vector.h:295 and vector.h354 Error in resize array vector.h:295 and vector.h354 Sep 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants