Python Forum
How to I make my program release memory?
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to I make my program release memory?
#11
Dumb mistake of mine, thank you :)

I followed the instructions you gave and I do indeed now have much larger swap memory, I do get some error messages though, it says "X11 connection rejected because of wrong authentication." when logging into the PI using SSH as well as when running my python program.

I am curious to why this was necessary though. I have a 8GB memory card so using 2GB of them for swap memory isn't ideal even though it's not a problem for this particular project. Isn't now my memory card acting as RAM? Which might also not be ideal when thinking of the limited read/write cycles that memory cards have.

I didn't have as much free space as I though, adding the 2GB swap file made it so that I could no longer run my program, out of memory it said. I undid the previous steps and erased the swap file, then redid everything only with a swap file of 1024MB in stead, but doing so made the swapon command to fail:

swapon: /home/pi/swap2.img: insecure permissions 0644, 0600 suggested.
swapon: /home/pi/swap2.img: read swap header failed

I will look into the sounddevice package, or perhaps I can find some other package that can do the job :)
Reply
#12
As you say using flash memory for swap isn't good cause multiple write operations. You didn't tell that that is the case. 
Anyway, you can check memory usage for application with top or htop command. The second one is more convenient but might be not installed. If 1GB suites you you may repeat the creation of the file, format it as a swap space and activate it again. If you keep path and the file name the same no need to edit /etc/fstab

You did it already... There is swapoff command. The computer may do some read/write on the swap so you Should turn it off before that. Unmount it, comment it in /etc/fstab, then do the same again with 1GB file. You have to be root or use sudo.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is it possible to make a program recognize how many clicks it has had on the monitor? jao 0 1,129 Feb-25-2022, 06:31 PM
Last Post: jao
  How to make a Vocal synthesizer program on Python? Seadust 3 3,490 Jan-28-2021, 06:26 PM
Last Post: gonnach
  How to make a Python program run in a dos shell (cmd) Pedroski55 2 2,257 Nov-09-2020, 10:17 AM
Last Post: DeaD_EyE
  I try to make Heron formula program abcd 7 3,329 Oct-22-2020, 12:48 AM
Last Post: abcd
  Make a Python program executable in Windows Pedroski55 1 2,067 Sep-26-2020, 12:34 AM
Last Post: bowlofred
  I code a program to solve puzzle but i can't make it more dynamic. Shahmadhur13 5 2,685 Apr-18-2020, 10:05 AM
Last Post: Shahmadhur13
  how to make a program with a certain number of multiples? syafiq14 3 2,694 Jan-01-2020, 02:39 PM
Last Post: syafiq14
  How to get mouse coordinates on click and release OhNoSegFaultAgain 1 2,957 May-17-2019, 06:56 PM
Last Post: buran
  How to make a program run "online"? DanielTkach 2 2,498 Apr-09-2019, 11:59 PM
Last Post: DanielTkach
  Python 3.4: the only release to create .EXE standalone without .dll samsonite 7 5,732 Feb-28-2019, 09:20 AM
Last Post: samsonite

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020