Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

The Contraption Bazaar Sticky

A topic by Internet Janitor created Feb 28, 2023 Views: 14,331 Replies: 144
Viewing posts 36 to 37 of 37 · Previous page · First page
(1 edit) (+2)

Memory Watcher

This contraption shows a log of Native Decker’s memory usage. I thought Decker was using a lot of memory, but it turned out that I just didn’t understand how it was supposed to work, and studying this helped me figure it out.

image.png

The graph scrolls to the right, so the newest data is on the left. The height of the graph represents the total size of Decker’s heap (which is given as a specific number in the caption at the top). The black lines represent how many allocations were added on that frame (“allocs” in the caption is the number of allocations in the most recent frame), and the dithered portion represents how full the heap is.

In the screenshot above, you can see the heap was pretty empty, then I did some things that created a lot of allocations, and the heap filled up. When it gets above 90% or so, Decker cleans up all the unused allocations, freeing up space to do more allocations in future.

The lesson I learned is that it’s better to do lots of small memory allocations over several frames than one big memory allocation, especially if there’s a chance your big memory allocation might happen when the heap is already quite full. Badly-timed allocations can balloon the heap until it’s 10 times bigger than your allocation, and that can be gigabytes of memory.

%%WGT0{"w":[{"name":"memwatcher1","type":"contraption","size":[199,45],"pos":[182,265],"def":"memwatcher","widgets":{"history":{"size":[199,45]},"lastallocs":{"size":[199,16],"pos":[0,77]},"lastheap":{"size":[199,16],"pos":[0,93]},"label":{"size":[199,45]}}}],"d":{"memwatcher":{"name":"memwatcher","size":[96,96],"resizable":1,"margin":[2,3,5,3],"description":"A live-updating log of Decker's memory usage.\n\nThe dithered area represents how full Decker's heap is, the solid area represents new allocations on that frame.","image":"%%IMG2AGAAYABQAQEA/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/ANI=","widgets":{"history":{"type":"canvas","size":[96,96],"pos":[0,0],"locked":1,"animated":1,"volatile":1,"script":"on view do\n # Extract values we'll need a lot\n lheap:0+lastheap.text\n cheap:sys.workspace.heap\n lallocs:0+lastallocs.text\n callocs:sys.workspace.allocs\n clive:sys.workspace.live\n cw:history.lsize[0]\n ch:history.lsize[1]\n\n\n # If the heap size has changed,\n # scale the histogram\n i:history.copy[0,0 history.lsize]\n if cheap > lheap\n  i:i.scale[1,lheap/cheap \"bottom_center\"]\n end\n\n # Scroll the histogram along\n history.clear[]\n history.paste[i (1,0) 0]\n\n # Draw a stipple for how full the heap is\n barh:ch*clive/cheap\n history.pattern:12\n history.line[0,ch 0,ch-barh]\n\n # Draw a solid line for how much was allocated this frame.\n barh:ch*(callocs-lallocs)/cheap\n history.pattern:1\n history.line[0,ch 0,ch-barh]\n\n label.text:\"heap:%i allocs:%i\" format cheap,callocs-lallocs\n\n lastheap.text:cheap\n lastallocs.text:callocs\nend","scale":1},"lastallocs":{"type":"field","size":[96,16],"pos":[0,128],"volatile":1},"lastheap":{"type":"field","size":[96,16],"pos":[0,144],"volatile":1},"label":{"type":"field","size":[96,96],"pos":[0,0],"locked":1,"volatile":1,"show":"transparent","border":0,"style":"plain","align":"right"}}}}}

Hello, I would like to ask a question. I apologize for not being able to understand the content in the "Path" tutorial. It is difficult for me, but I still want to use this plugin to add some interactivity to my visual novel. I want to make it so that when the character moves to different locations, different events and endings are triggered. I would really appreciate a straightforward video tutorial that teaches me how to use the "Path" plugin to create an interactive map. I am looking forward to your guidance, thank you very much.🥰

(+2)

Hi!

I'm sorry I'm not very good at making videos but hopefully this will still be helpful.

Where have you got so far with Path? As a starting point, you probably want to set something up like the "Follower animation demo" in the Path documentation. Essentially, copying what's there and changing the art to suit your purposes. There's an associated contraption that you'll need to import into your own deck to make this work.

The next part is making things trigger based on the movement. There's not really any set way to do this, but one way to do it is that when the follower has stopped walking, it calls a finish[] event, and you can put code in that event to check where the follower's current position is and make events happen accordingly.

I'm not sure if this makes much more sense than the tutorial, but if you can let me know which parts make sense and which parts don't we may be able to work it out.

Hello, thank you for your help and explanation. My exploration of Path is still limited to drawing a map and displaying the path from the starting point to the end point based on the clicked position. I'm still far away from using followers. Because my native language is not English, the text content in the tutorial is difficult for me to understand. So I adopted the simplest and crudest method, which is to copy each widget in the tutorial after installing the Path component on the local decker, and then change the values to explore the principle myself. However, when I applied the code to the map I drew myself, it failed. This is what troubled me in the first step.

(+1)

Hi. It would help if you uploaded your own deck, that way I can have a look and find out where it isn't working.

Viewing posts 36 to 37 of 37 · Previous page · First page