我目前正在运行 ubuntu 18.04 和 windows 10 的双启动设置。在 ubuntu 上构建一些代码时(同时打开了几个互联网选项卡),我的电脑会冻结并滞后到我需要执行 make -j1 之类的操作并关闭选项卡才能使其正常工作的程度。这越来越烦人了。我的瓶颈仅仅是内存不足吗?除了升级内存之外,我还能做其他什么吗?这是我的电脑冻结时系统进程的样子 这里
这就是我的 lshw 的样子
inspiron-5482
description: Convertible
product: Inspiron 5482 (089E)
vendor: Dell Inc.
serial: 8ZFY2P2
width: 64 bits
capabilities: smbios-3.2 dmi-3.2 smp vsyscall32
configuration: boot=normal chassis=convertible family=Inspiron sku=089E uuid=44454C4C-5A00-1046-8059-B8C04F325032
*-core
description: Motherboard
product: 0CVXN6
vendor: Dell Inc.
physical id: 0
version: A00
serial: /8ZFY2P2/CNWSC008BF000H/
*-firmware
description: BIOS
vendor: Dell Inc.
physical id: 0
version: 2.9.0
date: 12/28/2020
size: 64KiB
capacity: 15MiB
capabilities: pci pnp upgrade shadowing cdboot bootselect edd int13floppynec int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int9keyboard int14serial int17printer acpi usb smartbattery biosbootspecification netboot uefi
*-memory
description: System Memory
physical id: 29
slot: System board or motherboard
size: 8GiB
*-bank:0
description: SODIMM DDR4 Synchronous 2667 MHz (0.4 ns)
product: HMA81GS6CJR8N-VK
vendor: Hynix Semiconductor (Hyundai Electronics)
physical id: 0
serial: 2D84F6B4
slot: DIMM A
size: 8GiB
width: 64 bits
clock: 2667MHz (0.4ns)
*-bank:1
description: [empty]
physical id: 1
slot: DIMM B
*-cache:0
description: L1 cache
physical id: 32
slot: L1 Cache
size: 256KiB
capacity: 256KiB
capabilities: synchronous internal write-back unified
configuration: level=1
*-cache:1
description: L2 cache
physical id: 33
slot: L2 Cache
size: 1MiB
capacity: 1MiB
capabilities: synchronous internal write-back unified
configuration: level=2
*-cache:2
description: L3 cache
physical id: 34
slot: L3 Cache
size: 6MiB
capacity: 6MiB
capabilities: synchronous internal write-back unified
configuration: level=3
*-cpu
description: CPU
product: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
vendor: Intel Corp.
physical id: 35
bus info: cpu@0
version: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
serial: To Be Filled By O.E.M.
slot: U3E1
size: 3824MHz
capacity: 3900MHz
width: 64 bits
clock: 100MHz
capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities cpufreq
configuration: cores=4 enabledcores=4 threads=8
*-pci
description: Host bridge
product: Intel Corporation
vendor: Intel Corporation
physical id: 100
bus info: pci@0000:00:00.0
version: 0b
width: 32 bits
clock: 33MHz
configuration: driver=skl_uncore
resources: irq:0
*-display
description: VGA compatible controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 2
bus info: pci@0000:00:02.0
version: 00
width: 64 bits
clock: 33MHz
capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
configuration: driver=i915 latency=0
resources: irq:161 memory:a4000000-a4ffffff memory:80000000-8fffffff ioport:4000(size=64) memory:c0000-dffff
*-generic:0
description: Signal processing controller
product: Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem
vendor: Intel Corporation
physical id: 4
bus info: pci@0000:00:04.0
version: 0b
width: 64 bits
clock: 33MHz
capabilities: msi pm cap_list
configuration: driver=proc_thermal latency=0
resources: irq:16 memory:a5210000-a5217fff
*-generic:1 UNCLAIMED
description: System peripheral
product: Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th Gen Core Processor Gaussian Mixture Model
vendor: Intel Corporation
physical id: 8
bus info: pci@0000:00:08.0
version: 00
width: 64 bits
clock: 33MHz
capabilities: msi pm cap_list
configuration: latency=0
resources: memory:a522e000-a522efff
*-generic:2
description: Signal processing controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 12
bus info: pci@0000:00:12.0
version: 30
width: 64 bits
clock: 33MHz
capabilities: pm msi cap_list
configuration: driver=intel_pch_thermal latency=0
resources: irq:16 memory:a522d000-a522dfff
*-communication:0
description: Serial controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 13
bus info: pci@0000:00:13.0
version: 30
width: 64 bits
clock: 33MHz
capabilities: pm 8250 bus_master cap_list
configuration: driver=intel_ish_ipc latency=0
resources: irq:20 memory:a5224000-a5225fff
*-usb
description: USB controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 14
bus info: pci@0000:00:14.0
version: 30
width: 64 bits
clock: 33MHz
capabilities: pm msi xhci bus_master cap_list
configuration: driver=xhci_hcd latency=0
resources: irq:126 memory:a5200000-a520ffff
*-usbhost:0
product: xHCI Host Controller
vendor: Linux 5.4.0-74-generic xhci-hcd
physical id: 0
bus info: usb@1
logical name: usb1
version: 5.04
capabilities: usb-2.00
configuration: driver=hub slots=12 speed=480Mbit/s
*-usb:0
description: Keyboard
product: Gaming KB
vendor: SINO WEALTH
physical id: 1
bus info: usb@1:1
version: 12.62
capabilities: usb-1.10
configuration: driver=usbhid maxpower=500mA speed=12Mbit/s
*-usb:1
description: Keyboard
product: Microsoft Nano Transceiver 1.1
vendor: Microsoft
physical id: 3
bus info: usb@1:3
version: 3.15
capabilities: usb-2.00
configuration: driver=usbhid maxpower=100mA speed=12Mbit/s
*-usb:2 UNCLAIMED
description: Generic USB device
product: FingerPrint
vendor: Goodix
physical id: 5
bus info: usb@1:5
version: 1.00
capabilities: usb-2.00
configuration: maxpower=100mA speed=12Mbit/s
*-usb:3
description: Video
product: Integrated_Webcam_HD
vendor: CN0M1RXTLOG0087OC1K3A01
physical id: 6
bus info: usb@1:6
version: 85.02
capabilities: usb-2.01
configuration: driver=uvcvideo maxpower=500mA speed=480Mbit/s
*-usb:4
description: Bluetooth wireless interface
vendor: Intel Corp.
physical id: a
bus info: usb@1:a
version: 0.02
capabilities: bluetooth usb-2.00
configuration: driver=btusb maxpower=100mA speed=12Mbit/s
*-usbhost:1
product: xHCI Host Controller
vendor: Linux 5.4.0-74-generic xhci-hcd
physical id: 1
bus info: usb@2
logical name: usb2
version: 5.04
capabilities: usb-3.10
configuration: driver=hub slots=6 speed=10000Mbit/s
*-usb
description: Mass storage device
product: Ultra Fit
vendor: SanDisk
physical id: 2
bus info: usb@2:2
logical name: scsi1
version: 1.00
serial: 4C530001050825111423
capabilities: usb-3.00 scsi emulated scsi-host
configuration: driver=usb-storage maxpower=896mA speed=5000Mbit/s
*-disk
description: SCSI Disk
product: Ultra Fit
vendor: SanDisk
physical id: 0.0.0
bus info: scsi@1:0.0.0
logical name: /dev/sda
version: 1.00
serial: 4C530001050825111423
size: 28GiB (30GB)
capabilities: removable
configuration: ansiversion=6 logicalsectorsize=512 sectorsize=512
*-medium
physical id: 0
logical name: /dev/sda
size: 28GiB (30GB)
capabilities: partitioned partitioned:dos
*-volume
description: Windows FAT volume
physical id: 1
logical name: /dev/sda1
logical name: /media/shane/CBB1-222B
version: FAT32
serial: cbb1-222b
size: 28GiB
capacity: 28GiB
capabilities: primary fat initialized
configuration: FATs=2 filesystem=fat mount.fstype=vfat mount.options=rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro state=mounted
*-memory UNCLAIMED
description: RAM memory
product: Intel Corporation
vendor: Intel Corporation
physical id: 14.2
bus info: pci@0000:00:14.2
version: 30
width: 64 bits
clock: 33MHz (30.3ns)
capabilities: pm cap_list
configuration: latency=0
resources: memory:a5222000-a5223fff memory:a522c000-a522cfff
*-network
description: Wireless interface
product: Intel Corporation
vendor: Intel Corporation
physical id: 14.3
bus info: pci@0000:00:14.3
logical name: wlo1
version: 30
serial: 18:1d:ea:1f:7f:84
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=iwlwifi driverversion=5.4.0-74-generic firmware=46.6bf1df06.0 ip=192.168.0.106 latency=0 link=yes multicast=yes wireless=IEEE 802.11
resources: irq:16 memory:a521c000-a521ffff
*-serial:0
description: Serial bus controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 15
bus info: pci@0000:00:15.0
version: 30
width: 64 bits
clock: 33MHz
capabilities: pm bus_master cap_list
configuration: driver=intel-lpss latency=0
resources: irq:16 memory:7ec00000-7ec00fff
*-serial:1
description: Serial bus controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 15.1
bus info: pci@0000:00:15.1
version: 30
width: 64 bits
clock: 33MHz
capabilities: pm bus_master cap_list
configuration: driver=intel-lpss latency=0
resources: irq:17 memory:7ec01000-7ec01fff
*-communication:1
description: Communication controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 16
bus info: pci@0000:00:16.0
version: 30
width: 64 bits
clock: 33MHz
capabilities: pm msi bus_master cap_list
configuration: driver=mei_me latency=0
resources: irq:153 memory:a5229000-a5229fff
*-storage
description: SATA controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 17
bus info: pci@0000:00:17.0
version: 30
width: 32 bits
clock: 66MHz
capabilities: storage msi pm ahci_1.0 bus_master cap_list
configuration: driver=ahci latency=0
resources: irq:127 memory:a5220000-a5221fff memory:a5228000-a52280ff ioport:4090(size=8) ioport:4080(size=4) ioport:4060(size=32) memory:a5227000-a52277ff
*-pci:0
description: PCI bridge
product: Intel Corporation
vendor: Intel Corporation
physical id: 1c
bus info: pci@0000:00:1c.0
version: f0
width: 32 bits
clock: 33MHz
capabilities: pci pciexpress msi pm normal_decode bus_master cap_list
configuration: driver=pcieport
resources: irq:122
*-pci:1
description: PCI bridge
product: Intel Corporation
vendor: Intel Corporation
physical id: 1c.4
bus info: pci@0000:00:1c.4
version: f0
width: 32 bits
clock: 33MHz
capabilities: pci pciexpress msi pm normal_decode bus_master cap_list
configuration: driver=pcieport
resources: irq:123 ioport:3000(size=4096) memory:90000000-a30fffff
*-display
description: 3D controller
product: GM108M [GeForce MX130]
vendor: NVIDIA Corporation
physical id: 0
bus info: pci@0000:02:00.0
version: a2
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list rom
configuration: driver=nouveau latency=0
resources: irq:160 memory:a2000000-a2ffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:3000(size=128) memory:a3000000-a307ffff
*-pci:2
description: PCI bridge
product: Intel Corporation
vendor: Intel Corporation
physical id: 1d
bus info: pci@0000:00:1d.0
version: f0
width: 32 bits
clock: 33MHz
capabilities: pci pciexpress msi pm normal_decode bus_master cap_list
configuration: driver=pcieport
resources: irq:124 ioport:5000(size=4096) memory:7e800000-7e9fffff ioport:7ea00000(size=2097152)
*-pci:3
description: PCI bridge
product: Intel Corporation
vendor: Intel Corporation
physical id: 1d.4
bus info: pci@0000:00:1d.4
version: f0
width: 32 bits
clock: 33MHz
capabilities: pci pciexpress msi pm normal_decode bus_master cap_list
configuration: driver=pcieport
resources: irq:125 memory:a5100000-a51fffff
*-storage
description: Non-Volatile memory controller
product: Toshiba America Info Systems
vendor: Toshiba America Info Systems
physical id: 0
bus info: pci@0000:04:00.0
version: 01
width: 64 bits
clock: 33MHz
capabilities: storage pciexpress pm msi msix nvm_express bus_master cap_list
configuration: driver=nvme latency=0
resources: irq:16 memory:a5100000-a5103fff
*-nvme0
description: NVMe device
product: KBG30ZMS256G NVMe TOSHIBA 256GB
physical id: 0
logical name: /dev/nvme0
version: ADDA0103
serial: 989PD0N3PWFP
configuration: nqn=nqn.2017-03.jp.co.toshiba:KBG30ZMS256G NVMe TOSHIBA 256GB:989PD0N3PWFP state=live
*-namespace
description: NVMe namespace
physical id: 1
logical name: /dev/nvme0n1
size: 238GiB (256GB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: guid=6987e4e9-f4b3-4e66-a3e0-141975a6a22f logicalsectorsize=512 sectorsize=512
*-volume:0
description: Windows FAT volume
vendor: MSDOS5.0
physical id: 1
logical name: /dev/nvme0n1p1
version: FAT32
serial: de8c-66f8
size: 646MiB
capacity: 649MiB
capabilities: boot fat initialized
configuration: FATs=2 filesystem=fat label=ESP name=EFI system partition
*-volume:1
description: reserved partition
vendor: Windows
physical id: 2
logical name: /dev/nvme0n1p2
serial: a2f203e9-5e6f-433a-918c-1823dfd37c1b
capacity: 127MiB
capabilities: nofs
configuration: name=Microsoft reserved partition
*-volume:2
description: Windows FAT volume
vendor: -FVE-FS-
physical id: 3
logical name: /dev/nvme0n1p3
version: FAT32
serial: 0000-0000
size: 15EiB
capabilities: fat initialized
configuration: FATs=0 filesystem=fat name=Basic data partition
*-volume:3
description: Windows NTFS volume
vendor: Windows
physical id: 4
logical name: /dev/nvme0n1p4
version: 3.1
serial: c0b8-1046
size: 965MiB
capacity: 989MiB
capabilities: boot precious readonly hidden nomount ntfs initialized
configuration: clustersize=4096 created=2020-11-05 18:16:26 filesystem=ntfs modified_by_chkdsk=true mounted_on_nt4=true resize_log_file=true state=dirty upgrade_on_mount=true
*-volume:4
description: Windows NTFS volume
vendor: Windows
physical id: 5
logical name: /dev/nvme0n1p5
version: 3.1
serial: aa1e-72ce
size: 13GiB
capacity: 13GiB
capabilities: boot precious readonly hidden nomount ntfs initialized
configuration: clustersize=4096 created=2018-11-18 07:20:24 filesystem=ntfs label=Image modified_by_chkdsk=true mounted_on_nt4=true resize_log_file=true state=dirty upgrade_on_mount=true
*-volume:5
description: Windows NTFS volume
vendor: Windows
physical id: 6
logical name: /dev/nvme0n1p6
version: 3.1
serial: 583d-3637
size: 1087MiB
capacity: 1114MiB
capabilities: boot precious readonly hidden nomount ntfs initialized
configuration: clustersize=4096 created=2018-11-18 07:14:07 filesystem=ntfs label=DELLSUPPORT modified_by_chkdsk=true mounted_on_nt4=true resize_log_file=true state=dirty upgrade_on_mount=true
*-volume:6
description: EXT4 volume
vendor: Linux
physical id: 7
logical name: /dev/nvme0n1p7
version: 1.0
serial: 2a618b4a-27a6-49e1-8d2f-f2cdaae37a33
size: 52GiB
capabilities: journaled extended_attributes large_files huge_files dir_nlink recover 64bit extents ext4 ext2 initialized
configuration: created=2021-05-18 10:54:26 filesystem=ext4 lastmountpoint=/ modified=2021-06-21 01:25:04 mounted=2021-06-20 17:25:04 state=clean
*-isa
description: ISA bridge
product: Intel Corporation
vendor: Intel Corporation
physical id: 1f
bus info: pci@0000:00:1f.0
version: 30
width: 32 bits
clock: 33MHz
capabilities: isa bus_master
configuration: latency=0
*-multimedia
description: Audio device
product: Intel Corporation
vendor: Intel Corporation
physical id: 1f.3
bus info: pci@0000:00:1f.3
version: 30
width: 64 bits
clock: 33MHz
capabilities: pm msi bus_master cap_list
configuration: driver=snd_hda_intel latency=32
resources: irq:162 memory:a5218000-a521bfff memory:a5000000-a50fffff
*-serial:2 UNCLAIMED
description: SMBus
product: Intel Corporation
vendor: Intel Corporation
physical id: 1f.4
bus info: pci@0000:00:1f.4
version: 30
width: 64 bits
clock: 33MHz
configuration: latency=0
resources: memory:a5226000-a52260ff ioport:efa0(size=32)
*-serial:3 UNCLAIMED
description: Serial bus controller
product: Intel Corporation
vendor: Intel Corporation
physical id: 1f.5
bus info: pci@0000:00:1f.5
version: 30
width: 32 bits
clock: 33MHz
configuration: latency=0
resources: memory:fe010000-fe010fff
*-battery
product: DELL CYMGM89
vendor: Samsung SDI
physical id: 1
version: 09/24/2018
serial: D485
slot: Sys. Battery Bay
capacity: 41990mWh
configuration: voltage=11.4V
这是我的交换空间
total used free shared buff/cache available
Mem: 7643 2252 3537 517 1853 4607
Swap: 1392 0 1392
答案1
我得到了几个解决方案,一个是增加交换空间,另一个是增加 RAM,还有一个是通过在源文件中包含标头以及前向声明(我在 C++ 中编写代码)来优化标头依赖关系。
交换空间问题减少了我的电脑冻结。冻结之后,电脑速度就慢了很多,所以问题有所缓解,但并没有完全解决。
接下来,我尝试优化标头依赖关系以及前向声明,并且构建时间需要更少的 RAM 并花费更少的时间。
此时,我认为问题已经解决,因此不再升级内存。如果有其他建议可以让事情变得更加顺利,请分享。