The network icon of the virtual machine is missing | Shared folder identification does not exist

The company computer runs 2 virtual machines (16.04+20.04) and sometimes the network icon is lost when switching | shared folder identification does not exist

Network Icon Missing | Network Recovery

  • network.sh
#!/bin/bash

sudo service network-manager stop
sudo rm /var/lib/NetworkManager/NetworkManager.state
sudo service network-manager start
  • Just execute the script
~$ ./network.sh 

shared folder recovery

  • share.sh
#!/bin/bash

sudo vmhgfs-fuse  .host:/  /mnt/hgfs/  -o allow_other  -o uid=1000
  • Just execute the script
~$ ./share.sh
  • I don't know what's going on, so let's do it first



Reference: C/C++ Memory Distribution

1. The difference between malloc/free and new/delete

  • common ground:

They all apply for space from the heap and need to be released manually by the user

  • difference:
  1. malloc and free are functions, new and delete are operators

  2. The space requested by malloc will not be initialized, but new can be initialized

  3. When malloc applies for space, you need to manually calculate the size of the space and pass it on. New just needs to follow it with the type of space.

  4. The return value of malloc is void*, which must be forced when used, and new does not need it, because new is followed by the type of space

  5. When malloc fails to apply for space, it returns NULL, so it must be judged as empty when using it, new does not need it, but new needs to catch exceptions

  6. When applying for a custom type of object, malloc/free will only open up space, and will not call the constructor and destructor, while new will call the constructor to complete the initialization of the object after applying for space, and delete will call the destructor before releasing the space Complete the cleanup of resources in the space

2. How to apply for 4G of memory on the heap at one time

For a 32-bit stack, the virtual address space has a space size of 2 G

The size of the virtual address space is very large for a 64-bit stack

Example:

// 将程序编译成x64的进程,运行下面的程序
#include <iostream>
using namespace std;
int main()
{
    
    
	void* p = new char[0xfffffffful];
	cout << "new:" << p << endl;
	return 0;
}

1G = 2^30 Bytes
ul: unsigned long integer
0xffff ffff= 4294967295
(4294967295+1) / 2^30 = 4 G

0x7FFFFFFF = 2147483647
(2147483647+1) / 2^30 = 2 G

  • Platform vs2019x32:
    insert image description here

  • Platform vs2019x64:
    insert image description here

Guess you like

Origin blog.csdn.net/qq_47355554/article/details/127963001