LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-23-2023, 11:24 PM   #16
Matthew Wai
Member
 
Registered: Jul 2019
Location: China
Distribution: UnionTech OS Desktop Home (64-bit)
Posts: 200

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by pan64 View Post
did you read the post I sent?
I just did the following test:
Code:
Matthew_Wai@My-PC:~$ free -h
              total        used        free      shared  buff/cache   available
Mem:          5.7Gi       880Mi       2.6Gi        59Mi       2.3Gi       4.5Gi
Swap:         2.0Gi          0B       2.0Gi
Matthew_Wai@My-PC:~$ sudo systemctl stop HDD_temp && sudo systemctl start HDD_temp
[sudo] password for Matthew_Wai: 
Verification successful
Matthew_Wai@My-PC:~$ free -h
              total        used        free      shared  buff/cache   available
Mem:          5.7Gi       888Mi       2.4Gi        59Mi       2.4Gi       4.5Gi
Swap:         2.0Gi          0B       2.0Gi
Matthew_Wai@My-PC:~$
The above output shows the following:
(1) "buff/cache" was "2.3Gi" originally.
(2) The service was restarted.
(3) "buff/cache" was "2.4Gi" after the restart.

Restarting the service did not clear the cache.

Last edited by Matthew Wai; 11-23-2023 at 11:25 PM.
 
Old 11-23-2023, 11:30 PM   #17
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,996

Rep: Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338
are you sure you can manage the memory better than the kernel itself (which was developed to do this). see post #5.
But there is another question here too: are you sure kernel won't free it up by itself if that memory will be needed for something more important?

Actually it is not a simple shell script, it invokes at least 5-6 additional tools, like sudo, date, service, grep, hddtemp.

Quote:
Originally Posted by Matthew Wai View Post
Restarting the service did not clear the cache.
Obviously, it won't do that, just tells the kernel that the memory/cache used by this service is not needed any more.
As you can see you have a lot of memory available, why don't you allow the kernel to use it for something useful (speed up something a bit)?

Last edited by pan64; 11-23-2023 at 11:35 PM.
 
Old 11-24-2023, 03:06 AM   #18
Matthew Wai
Member
 
Registered: Jul 2019
Location: China
Distribution: UnionTech OS Desktop Home (64-bit)
Posts: 200

Original Poster
Rep: Reputation: Disabled
Both the service and the script were written by me.
Both work fine after the service is restarted.
I am not smart enough to figure out why the service should not be restarted.
 
Old 11-24-2023, 04:30 AM   #19
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,818

Rep: Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211
I wonder if your shell script will ever log "Failure".?
But I have no explanation why it should consume MBs of memory.

The following variant has a loop with max 200 cycles of service starts, and a 1s sleep in between.
Code:
#!/bin/bash
S="Failure"
sleep 10
for ((N=0; N < 200; N++)) ; do
  if service fancontrol status|grep running; then
    S="Success"; break
  fi
  sudo service fancontrol start
  sleep 1
done
File=/@/Fancontrol/Log
echo "$(date) ${S}" >> "${File}"

while : ; do
  T=$(sudo hddtemp -n /dev/sda)
  echo $((T * 1000)) > "/@/Fancontrol/Hddtemp"
  sleep 30
done

Last edited by MadeInGermany; 11-24-2023 at 04:31 AM.
 
Old 11-24-2023, 04:57 AM   #20
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,996

Rep: Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338
Quote:
Originally Posted by Matthew Wai View Post
Both the service and the script were written by me.
Both work fine after the service is restarted.
I am not smart enough to figure out why the service should not be restarted.
I'm not really convinced that restarting the service will help anything. You need to make at least more measurements and more precise measurements to be sure.
 
Old 11-24-2023, 05:36 AM   #21
Matthew Wai
Member
 
Registered: Jul 2019
Location: China
Distribution: UnionTech OS Desktop Home (64-bit)
Posts: 200

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
I wonder if your shell script will ever log "Failure".?
The variable "${S}" is empty by default. “Failure” will appear as long as "${S}" remains empty.
I have never seen “Failure” in the “Log” file, as the following command never fails repeatedly.
sudo service fancontrol start

Quote:
Originally Posted by MadeInGermany View Post
But I have no explanation why it should consume MBs of memory.
After restarting the service, it uses 496 KB, which is reasonable. See below:
Code:
Matthew_Wai@My-PC:~$ service HDD_temp status|grep "Memory"
   Memory: 496.0K
Matthew_Wai@My-PC:~$
 
Old 11-24-2023, 08:00 AM   #22
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,818

Rep: Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211Reputation: 1211
Quote:
“Failure” will appear as long as "${S}" remains empty.
But it won't leave your loop if $S is empty.
Code:
while [ -z "${S}" ]
Perhaps you want to log "Failure" within the loop not after it?

Last edited by MadeInGermany; 11-24-2023 at 08:07 AM.
 
Old 11-24-2023, 10:14 PM   #23
Matthew Wai
Member
 
Registered: Jul 2019
Location: China
Distribution: UnionTech OS Desktop Home (64-bit)
Posts: 200

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
But it won't leave your loop if $S is empty.
Code:
while [ -z "${S}" ]
The loop will end even if "${S}" is empty. The reason is shown below:
Code:
for ((N=0;N<20;N++))
The loop will not be an endless loop.
 
Old 11-24-2023, 10:22 PM   #24
Matthew Wai
Member
 
Registered: Jul 2019
Location: China
Distribution: UnionTech OS Desktop Home (64-bit)
Posts: 200

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
But I have no explanation why it should consume MBs of memory.
One possible explanation is that there is a bug in the kernel or the memory management code.
 
Old 11-25-2023, 08:48 AM   #25
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,996

Rep: Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338
Quote:
Originally Posted by Matthew Wai View Post
One possible explanation is that there is a bug in the kernel or the memory management code.
Obviously, this cannot be ruled out. It's just almost impossible. The Linux kernel is currently used on countless hosts (millions or even billions of devices and VMs) and has been running for decades, not just years. Such an error should have been detected and corrected a long time ago. Otherwise, all of these systems would inevitably be unstable and unreliable

Last edited by pan64; 11-25-2023 at 08:56 AM.
 
Old 11-25-2023, 08:53 AM   #26
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,996

Rep: Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338
Quote:
Originally Posted by Matthew Wai View Post
The loop will end even if "${S}" is empty. The reason is shown below:
Code:
for ((N=0;N<20;N++))
The loop will not be an endless loop.
the for loop is not an endless loop, the while loop you wrote is an endless loop, if fancontrol cannot be started this loop will just run forever. If the "service | grep" command always fails, it never sets S to anything.
 
Old 11-26-2023, 05:46 AM   #27
Matthew Wai
Member
 
Registered: Jul 2019
Location: China
Distribution: UnionTech OS Desktop Home (64-bit)
Posts: 200

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
But it won't leave your loop if $S is empty.
Quote:
Originally Posted by pan64 View Post
the while loop you wrote is an endless loop
I have just broken the loop by adding two conditions as shown below:
Code:
while [ -z "${S}" ];do for ((N=0;N<20;N++));do sleep 5s 
service fancontrol status|grep running && S="OK" && N=20
if [ -z "${S}" ];then sudo service fancontrol start;fi;done
if [ "${N}" == "20" ]&&[ -z "${S}" ];then S="Failed";fi;done
 
Old 11-26-2023, 06:01 AM   #28
Matthew Wai
Member
 
Registered: Jul 2019
Location: China
Distribution: UnionTech OS Desktop Home (64-bit)
Posts: 200

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
Such an error should have been detected and corrected a long time ago. Otherwise, all of these systems would inevitably be unstable and unreliable
A waste of 200 MB of memory will not cause an error, instability, or unreliability.
 
Old 11-26-2023, 09:05 AM   #29
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,996

Rep: Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338
Quote:
Originally Posted by Matthew Wai View Post
A waste of 200 MB of memory will not cause an error, instability, or unreliability.
That is wrong. Any [unpredictable] memory leak will lead to crash sooner or later. And actually wasting a single byte (not 200MB) under any circumstances is very dangerous, unacceptable.
 
Old 11-26-2023, 10:08 PM   #30
Matthew Wai
Member
 
Registered: Jul 2019
Location: China
Distribution: UnionTech OS Desktop Home (64-bit)
Posts: 200

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
That is wrong. Any [unpredictable] memory leak will lead to crash sooner or later. And actually wasting a single byte (not 200MB) under any circumstances is very dangerous, unacceptable.
I did not mean a memory leak. When I wrote "a waste of 200 MB", I meant the memory usage could safely be reduced.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is the Perl programming language sharply decreasing in popularity? punchy71 Programming 17 05-06-2015 09:06 AM
RAID10 write speed decreased to normal SSD speed after rebuilding the array. mke2k Linux - Server 2 07-11-2014 04:15 AM
LXer: Gartner: Server sales up sharply in 2005 LXer Syndicated Linux News 0 02-22-2006 01:01 PM
is it possible that hardware support decreased from kern 2.4 to 2.6? (and other kern servnov Linux - Newbie 3 11-11-2004 04:59 PM
Viruses aimed at Microsoft rise sharply Micro420 Linux - Security 11 09-21-2004 01:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration