Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Cannot allocate item. Out of ID numbers (max 1000)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chopperdudes




PostPosted: Sat Jan 03, 2009 4:42 pm   Post subject: Cannot allocate item. Out of ID numbers (max 1000)

okay guys came across a pretty serious problem. i'm run into this problem even though i'm freeing the pictures. this happens when for example when i have to scale an image many times inside a loop. even though i'm freeing the pictures each time after drawing it, because i'm using the same local picture ID variable, this happens.

what can i do?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Jan 03, 2009 5:21 pm   Post subject: RE:Cannot allocate item. Out of ID numbers (max 1000)

are you using Pic.Free on that variable?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: Sat Jan 03, 2009 5:42 pm   Post subject: RE:Cannot allocate item. Out of ID numbers (max 1000)

Out of ID numbers? I usually get illegal picture ID 1001.

Remember that pictures are only put into one spot in memory and all variables that use that picture are references to that piece of memory.
andrew.




PostPosted: Sun Jan 04, 2009 11:52 am   Post subject: RE:Cannot allocate item. Out of ID numbers (max 1000)

This happens even if you use Pic.Free. I don't know why though. And Tony, he is using Pic.Free, he said he's freeing the pictures.
Insectoid




PostPosted: Sun Jan 04, 2009 11:56 am   Post subject: RE:Cannot allocate item. Out of ID numbers (max 1000)

Why don't you show us your code, chopperdudes? That way we can identify the problem and help you figure out how to fix it.
chopperdudes




PostPosted: Sun Jan 04, 2009 9:08 pm   Post subject: Re: Cannot allocate item. Out of ID numbers (max 1000)

hmm guys here's a simple code that would produce the exact same error. That error i get right now is really rare in my program, but because i can make the error happen so easily with such a simple piece of code, i know it can happen to my program too.

code:

loop
    var picID := Pic.Scale (Pic.New (0, 0, maxx, maxy), 10, 10)
    locate (1, 1)
    put picID
    Pic.Free (picID)
end loop


i've tried to put the var declaration outside of the loop, do the Pic.New and Pic.Scale in 2 separate steps, nothing seems to work.
DarkRider




PostPosted: Sun Jan 04, 2009 9:15 pm   Post subject: RE:Cannot allocate item. Out of ID numbers (max 1000)

Your problem is that you're never actualy freeing the picture you create with Pic.New (). You need to create a variable to hold the picture you create and then free it before you make another picture:

Turing:
var newPic : int
var picID : int
loop
    newPic := Pic.New (0, 0, maxx, maxy)
    picID := Pic.Scale (newPic, 10, 10)
    locate (1, 1)
    put picID
    Pic.Free (picID)
    Pic.Free (newPic)
end loop
chopperdudes




PostPosted: Sun Jan 04, 2009 10:30 pm   Post subject: RE:Cannot allocate item. Out of ID numbers (max 1000)

wow okay that sucks lol. Thanks DarkRider!!!

that's gonna add quite a few unnecessary lines for my proggy =(, need to have a tempPic for everything.
Sponsor
Sponsor
Sponsor
sponsor
The_Bean




PostPosted: Sun Jan 04, 2009 11:05 pm   Post subject: Re: Cannot allocate item. Out of ID numbers (max 1000)

Well Pic.Free doesn't solve all the problems, if you make and free around 20,000 pictures on a computer with 2 gig of ram eventually Turing will fill the ram and crash with an error saying not enough memory to create picture, and because it crashed the pictures won't be freed from the memory causing you're computer to move really slow until you manually free it or restart your computer.
(2 pictures with Pic.Rotate at 55 fps for 3 min)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: